AFNetworking收到正确的响应,但解析返回错误。我明白,我在经理中设置错误,但无法理解,这是对的。
我的代码:
manager = [[AFHTTPSessionManager alloc] initWithBaseURL:kAuthorizationUrl];
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/x-plist",nil];
[manager POST:@"someURL" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject){
NSLog(@"");
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"");
}];
返回错误:
"No value for key in object around character 35."
邮递员的回应:
{
"featureAppleTVSynchronisation" = "false";
"featureDirectPlay" = "true";
"googleLoginSwitchOn" = "true";
}
回复标题:
Accept-Ranges →bytes
Access-Control-Allow-Credentials →true
Access-Control-Allow-Methods →GET, POST, OPTIONS
Connection →keep-alive
Content-Encoding →gzip
Content-Type →application/x-plist; charset=UTF-8
Date →Tue, 18 Oct 2016 19:57:05 GMT
Server →Apache/2.4.6 (CentOS)
Transfer-Encoding →chunked
Vary →Accept-Encoding
X-Varnish-Retries →0
cache-control →private, no-cache, no-store, must-revalidate, max-age=0
expires →Tue, 18-Oct-2016 19:00:28 GMT
答案 0 :(得分:1)
好的,我找到了解决方案: 正确的代码
manager = [[AFHTTPSessionManager alloc] initWithBaseURL:kAuthorizationUrl];
// Attention please! Here is what I changed!
manager.responseSerializer = [AFPropertyListResponseSerializer serializer];
// End
[manager POST:@"someURL" parameters:parameters progress:nil success:^(NSURLSessionDataTask * _Nonnull task, id _Nullable responseObject){
NSLog(@"");
} failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"");
}];