AFNetwork报错

报错1:

"_kUTTagClassFilenameExtension", referenced from:
"_kUTTagClassMIMEType", referenced from:
"_UTTypeCreatePreferredIdentifierForTag", referenced from:
"_UTTypeCopyPreferredTagWithClass", referenced from:

在项目中添加以下框架:
MobileCoreServices.framework
SystemConfiguration.framework

报错2:

Error Domain=NSCocoaErrorDomain Code=3840 "JSON text did not start with array or object and option to allow fragments not set."
或者
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)"

这个错误是服务器返回数据json格式不对

报错3

这个就有点奇葩了,服务器说oc传上去的字典解析出来是"key" = "value",说有等号不对,必须是冒号(╯‵□′)╯︵┻━┻,这个的话就把字典再转成json字符串传上去就可以了,如:

NSDictionary *parameters = @{@"getInfo":info,@"uid":openID};

NSData *jsonData = [NSJSONSerialization dataWithJSONObject:parameters options:NSJSONWritingPrettyPrinted error:nil];

NSString *getInfo = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];

NSLog(@"上传参数%@",getInfo);

报错4

参数中带有字典
这个错误就更奇葩了,和php研究了好半天,才找到解决方法,特别记录一下,解决方法就是先把参数中的字典转成json字符串,然后把字典当做json字符串传过去就OK了,字典怎么转json上面已经说了。

你可能感兴趣的:(AFNetwork报错)