Say I have this method that given a URL returns a UIImage:
- (void)getUIImageFromURL:(NSURL *)URL {
NSURLRequest *request = [NSURLRequest requestWithURL:
The callback block in setCompletionBlockWithSuccess:
is a void block, you can't change it's return type.
In your case, you would probably set the image inside of your block, instead of returning an image.
[imageOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
self.myImage.image = [UIImage imageWithData:responseObject];
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
However, if you are dealing with AFNetworking and images, there are category methods that should greatly simplify retrieval and cacheing.
[self.myImage setImagewithURL:URL];