Jak zwrócić zmienną z bloku wewnątrz metody?
Powiedzmy, że mam tę metodę, która podała URL zwraca UIImage:
- (void)getUIImageFromURL:(NSURL *)URL {
NSURLRequest *request = [NSURLRequest requestWithURL:URL];
AFHTTPRequestOperation *imageOperation = [[AFHTTPRequestOperation alloc] initWithRequest:request];
imageOperation.responseSerializer = [AFImageResponseSerializer serializer];
[imageOperation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) {
return (UIImage *)responseObject;
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
}];
[imageOperation start];
}
Ale wciąż daje mi ten błąd:
Niezgodne typy wskaźników blokowych wysyłających „UIImage * (^) (AFHTTPRequestOperation * __ strong, _strong id) 'do parametru type' void (^) (AFHTTPRequestOperation *_strong, __ silny identyfikator) '
Jestem trochę nowy w blokach, więc może zbliżam się do tego całkowicie wstecz. Jak najlepiej wdrożyć taką metodę?