错误:Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage

来源:互联网 发布:c4d r16 mac 注册机 编辑:程序博客网 时间:2024/05/29 07:33

iOS 错误:Error Domain=NSCocoaErrorDomain Code=3840 "Garbage at end." UserInfo={NSDebugDescription=Garbage at end.}


今天突然发现有些窗口请求失败,赶紧排查修复,

一开始就想到是后台的问题,可是安卓说没问题,有数据接收

然后自己看输出日记

发现来到AFNetworking后就跳出来了,

把链接拷到浏览器打开,有json数据输出,

只能网上搜搜答案

在 http://stackoverflow.com/questions/10363274/nsjsonserialization-how-to-convert-json-into-nsarray-properly 中发现了一个重要的信息


It's pretty obvious that you indeed have 'garbage' at the end. You have a JavaScript block that although is not visible in the browser, it's still returning from your php script. Remove that and you should be good to go.

很明显,你确实有'垃圾'结尾。你有一个JavaScript块,虽然不是在浏览器中可见,它仍然从你的PHP脚本返回。删除这一点,你应该是好去。


遇到这种情况,可以试下打印data的字符串 NSLog(@"%@", [[NSString alloc] initWithData:contentData encoding:NSUTF8StringEncoding]);

在这字符串的最后,多了一个JavaScript block,叫后台处理一下就好了.



1 0
原创粉丝点击