2013-10-15 62 views
2

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

当我使用此代码:

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 

回答

3

Incompatible pointer types assigning to 'AFHTTPResponseSerializer *' from 'AFPropertyListRequestSerializer *'

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

您可能想改为使用AFPropertyListResponseSerializer

+0

谢谢。错误和警告消失了。现在唯一的问题是,现在ActivityIndi​​cator旋转不停,没有plist加载。它甚至没有在代码id propertyList){控制台中的代码后显示NSLog。 – user2211417

+0

不客气。你所面临的问题似乎超出了这个问题的范围。你可以尝试用'[[NSOperationQueue mainQueue] addOperation:operation];'而不是调用'start'开始操作,但我认为你应该发布另一个更具体的问题。 –