AFNetworking 2.0 – 如何下载asynchronous

在使用AFNetworking 2.0的ios中,我怎样才能轻松地asynchronous下载一个远程镜像,并将其caching到相同url的未来请求中? 我正在寻找一个方便的方式来接收错误callback和成功的。

谢谢

你可以做

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]; 

也提到如何使用AFNetworking 2.0下载图像?