所以在AFNetworking中有一个函数如下:
+ (AFImageRequestOperation *)imageRequestOperationWithRequestNSURLRequest *)urlRequest
imageProcessingBlockUIImage *(^)(UIImage *))imageProcessingBlock
cacheNameNSString *)cacheNameOrNil
successvoid (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
failurevoid (^)(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error))failure
{
我正在尝试按如下方式使用它:
[AFImageRequestOperation imageRequestOperationWithRequest:nil imageProcessingBlock:^UIImage * (UIImage *) {
}cacheName"nsurl" success:^(NSURLRequest *request, NSHTTPURLResponse * response, UIImage * image){
}failure:^(NSURLRequest *request, NSHTTPURLResponse * response, NSError * error){
}];
但是 UIImage 部分似乎不正确.. 有什么想法吗?
您快到了 - 您的代码在第一个 block 中缺少图像的参数名称:
[AFImageRequestOperation imageRequestOperationWithRequest:nil imageProcessingBlock:^UIImage * (UIImage *image) { // <<== HERE
} cacheName"nsurl" success:^(NSURLRequest *request, NSHTTPURLResponse * response, UIImage * image){
}failure:^(NSURLRequest *request, NSHTTPURLResponse * response, NSError * error){
}];
我认为这是 Xcode 中的一个错误,因为它将签名扩展为您发布的内容,没有参数名称。
关于iphone - 使用返回并接受参数的 block ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10628447/
欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://jike.in/) | Powered by Discuz! X3.4 |