Tag: 客户 客户 客户 客户 客户 客户 客户

如何从方法内的块返回variables?

说我有这个方法给定一个URL返回一个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]; } 但它一直给我这个错误: 向' void(^)(AFHTTPRequestOperation * _strong,__strong id)'参数发送'UIImage *(^)(AFHTTPRequestOperation * __ strong,_ strong id)'的不兼容块​​指针types 我有点新的块,所以也许我完全倒退了。 如何最好的实现这样的方法?