I have method that get notification as I download one image. I can download a lot of objects and I want to update tableView then I have last notification of downloaded image. How the best way to accomplish it?
- (void)requestDownloadAvatarWithImageString:(NSString *)imageString completion:(void (^)(AFHTTPRequestOperation *operation, UIImage *image, NSError *error))completion __attribute__((nonnull(2)))
{
NSParameterAssert(completion);
NSString *urlString = imageString;
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) {
completion(operation, responseObject, nil);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
DDLogError(@"FAIL download image: %@",error);
}];
[requestOperation start];
}