我想在即将到来的图像中创建方法,并且所有这些都在队列中逐个下载。我使用AFNetworking 2.0。我想知道是否有任何预先创建的代码可以帮助我解决问题?
我的代码
NSString *urlString = link;
NSURL *url = [NSURL URLWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
UIImage *image = responseObject;
//here I seve image to disk and so on
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
DDLogError(@"FAIL download image: %@",error);
}];
答案 0 :(得分:0)
尝试使用dispatch_group:所有下载都分组到一个队列中并逐个下载