How to download uiimage async
In ios using AFNetworking 2.0 how can I easily download a remote image asynchronously and cache it for future request of the same url? I'm looking for a convenient way to receive both error callbacks and successful ones.
Thanks
You can do
AFHTTPRequestOperation *requestOperation = [[AFHTTPRequestOperation alloc] initWithRequest:urlRequest];
requestOperation.responseSerializer = [AFImageResponseSerializer serializer];
[requestOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Response: %@", responseObject);
_imageView.image = responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Image error: %@", error);
}];
[requestOperation start];
also mentioned How to download image with AFNetworking 2.0?
链接地址: http://www.djcxy.com/p/96766.html上一篇: 如何获得AFNetworking 2.0的下载进度?
下一篇: 如何下载uiimage async