I would recommend using the following template for loading images with progress:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
manager.responseSerializer = [AFImageResponseSerializer serializer];
manager.requestSerializer.cachePolicy = NSURLRequestReloadIgnoringLocalAndRemoteCacheData;
[manager GET:url.absoluteString parameters:nil progress:^(NSProgress * _Nonnull downloadProgress) {
float progress = downloadProgress.fractionCompleted;
} success:^(NSURLSessionTask *task, id responseObject) {
UIImage *responseImage = responseObject;
} failure:^(NSURLSessionTask *operation, NSError *error) {
NSLog(Failed with error: %@", error);
}];
and this template for downloading videos with progress:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
NSURLSessionDownloadTask *downloadTask = [manager downloadTaskWithRequest:request progress:^(NSProgress * _Nonnull downloadProgress) {
float progress = downloadProgress.fractionCompleted;
} destination:^NSURL * _Nonnull(NSURL * _Nonnull targetPath, NSURLResponse * _Nonnull response) {
NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:NO error:nil];
return [documentsDirectoryURL URLByAppendingPathComponent:[response suggestedFilename]];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if(error) {
NSLog(Error %@", error);
}
else {
NSString *path = filePath.relativeString;
}
}
}];
[downloadTask resume];
I hope this helps!