You need
+ (NSArray *)batchOfRequestOperations:(NSArray *)operations
progressBlock:(void (^)(NSUInteger numberOfFinishedOperations, NSUInteger totalNumberOfOperations))progressBlock
completionBlock:(void (^)(NSArray *operations))completionBlock
method of AFURLConnectionOperation.
Please look at the following sample
NSMutableArray *operations = [NSMutableArray array];
for (DGSocialImage *socialImage in socialImages) {
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:socialImage.url];
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFImageResponseSerializer new];
[operations addObject:operation];
}
NSArray *batchOperations = [AFURLConnectionOperation batchOfRequestOperations:operations
progressBlock:NULL
completionBlock:^(NSArray *operations) {
NSError *error;
for (AFHTTPRequestOperation *op in operations) {
if (op.isCancelled){
return ;
}
if (op.responseObject){
// process your responce here
}
if (op.error){
error = op.error;
}
}
}];
[[NSOperationQueue mainQueue] addOperations:batchOperations waitUntilFinished:NO];