2012-05-17 89 views
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部分是正確的..任何想法?

回答

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中的錯誤,因爲它擴大了簽名爲您發佈正是,沒有參數名稱。

相關問題