英语轻松读发新版了,欢迎下载、更新

使用AFNetworking,遇到如下问题,求帮助!

rth 发布于 2015年02月10日 | 更新于 2015年03月09日
无人欣赏。
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (No string key for value in object around character 1.) UserInfo=0x156b3c50 {NSDebugDescription=No string key for value in object around character 1.}
共2条回复
Secret 回复于 2015年03月09日

The problem comes from response parsing. You are trying to de-serialize a JSON reponse (which MUST be contained in either a NSArray or NSDictionary) however your response is none of the above (Most likely a simple string).

Also, try to set the "allow fragments" to the response serializer. AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];

via. stackoverflow

Secret 回复于 2015年03月09日

The problem comes from response parsing. You are trying to de-serialize a JSON response (which MUST be contained in either a NSArray or NSDictionary) however your response is none of the above (Most likely a simple string).

Also, try to set the "allow fragments" to the response serializer. AFJSONResponseSerializer *responseSerializer = [AFJSONResponseSerializer serializerWithReadingOptions:NSJSONReadingAllowFragments];

via. stackoverflow

登录 或者 注册