afnetworking NSCocoaErrorDomain Code=3840 解决
2024-10-21 09:45:50
afnetworking json解析出错
解决方法1
AFURLResponseSerialization.m
258行修改
responseString = [responseString stringByReplacingOccurrencesOfString:@"\r\n" withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\n" withString:@""];
responseString = [responseString stringByReplacingOccurrencesOfString:@"\t" withString:@""];
data = [responseString dataUsingEncoding:NSUTF8StringEncoding];
解决方法2
数据请求失败
Error Domain=NSCocoaErrorDomain Code=3840 "The operation couldn’t be completed. (Cocoa error 3840.)" (JSON text did not start with array or object and option to allow fragments not set.) UserInfo=0x9b7eba0 {NSDebugDescription=JSON text did not start with array or object and option to allow fragments not set.}
解决:
AFNetWorking的JSON解析默认库是使用的AFJSONRequestOperation模式,只支持text/json,application/json,text/javascript,所以如果出现code=-1016错误则说明当前的JSON解析模式是text/html,所以要加上这段代码:
最新文章
- POJ 3667 Hotel(线段树 区间合并)
- 点击div折叠
- [Android]AndroidBucket增加碎片SubLayout功能及AISubLayout的注解支持
- 常用SQL语句优化技巧
- 您需要来自administrators的权限才能对此文件进行更改
- cocos2d-x for js 继承的写法
- Linux串口调试
- Cinder-1 TinderBox
- sockaddr结构体
- Kubernetes初探[1]:部署你的第一个ASP.NET Core应用到k8s集群
- 【SQL】ROW_NUMBER() OVER(partition by 分组列 order by 排序列)用法详解+经典实例
- SSM 框架 整合<;SpringMVC+Spring+MyBatis>;
- ionic使用cordova插件中的Screenshot截图分享功能
- Numpy:索引与切片
- Godaddy新手教程
- 使用eclipse在linux下开发C/C++
- js 时间日期函数小结
- 【最简单】不用ps也可以批量转换图片格式
- jquery 图片预加载
- 报错 ERROR in static/js/vendor.b3f56e9e0cd56988d890.js from UglifyJs