2

所以在AFNetworking中有一个函数如下:

+ (AFImageRequestOperation *)imageRequestOperationWithRequest:(NSURLRequest *)urlRequest
                                         imageProcessingBlock:(UIImage *(^)(UIImage *))imageProcessingBlock
                                                    cacheName:(NSString *)cacheNameOrNil
                                                      success:(void (^)(NSURLRequest *request, NSHTTPURLResponse *response, UIImage *image))success
                                                      failure:(void (^)(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 部分似乎不正确..有什么想法吗?

4

1 回答 1

3

您快到了 - 您的代码在第一个块中缺少图像的参数名称:

[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 中的一个错误,因为它将签名扩展为您发布的内容,而没有参数名称。

于 2012-05-17T00:31:21.990 回答