2

我试图将我的应用程序迁移到 iOS 7,因此我必须使用 AFNetworking 2.0。

当我使用此代码时:

NSURL *plistURL = [NSURL URLWithString:@"/test.php"];
NSURLRequest *request = [NSURLRequest requestWithURL:plistURL];

AFHTTPRequestOperation *operation =
        [[AFHTTPRequestOperation alloc] initWithRequest:request];
operation.responseSerializer = [AFPropertyListRequestSerializer serializer];
[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id propertyList) {

//some code

 }failure:nil];

[operation start];

}

我收到警告,编译时出现错误:警告:

Incompatible pointer types assigning to 'AFHTTPResponseSerializer<AFURLResponseSerialization> *' from 'AFPropertyListRequestSerializer *'

错误:

AFPropertyListRequestSerializer responseObjectForResponse:data:error:]: unrecognized selector sent to instance 0xdd83160
4

1 回答 1

4

从“AFPropertyListRequestSerializer *”分配给“AFHTTPResponseSerializer *”的不兼容指针类型

错误很明显。您正在将请求序列化程序分配给响应序列化程序,当然,它不起作用。

您可能想改用 a AFPropertyListResponseSerializer

于 2013-10-15T21:32:16.020 回答