AFHTTPRequestOperation

AFHTTPRequestOperation

我正在尝试运行以下代码:

#import "AFNetworking.h"
#import "AFHTTPRequestOperation.h"

AFImageRequestOperation *operation = [[AFImageRequestOperation alloc] initWithRequest:request];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject){
     NSLog(@"%@", operation.responseData); // Data
     NSLog(@"%@", [responseObject class]); // UIImage
 } failure:^(AFHTTPRequestOperation *operation, NSError *error) {}];

但是有这些错误:

未知类型名称AFImageRequestOperation;你是说AFHTTPRequestOperation吗?
未知的接收者AFImageRequestOperation;你是说AFHTTPRequestOperation吗?

最佳答案

this github issue中所述:

现在,您将使用常规的AFHTTPRequestOperation并设置其
对AFImageResponseSerializer对象的responseSerializer对象(可能是
[AFImageResponseSerializer序列化器]。

您可以阅读Migration Guide以了解全部内容
序列化的想法。

08-05 23:49