1. 错误打印  code=-1016 filed: text/html

错误原因:AFN默认不能解析请求回来的text/html数据

解决办法:

AFN3.0的请看这里

AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];

[manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/html", nil]];

AFN2.X的看这里

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager.responseSerializer setAcceptableContentTypes:[NSSet setWithObjects:@"text/html", nil]];

注意把所有的 AFN弄成-fobjc-arc (如果你的AFN是从GITHub上下的, AFN是ARC版本的)

2. 错误打印:code1002问题,get请求https的网址

(1)  在 NSURLConnection 旁边添加这个方法

- (void)connection:(NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge

{

if ([challenge previousFailureCount] == 0) {

NSURLCredential *cre = [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust];

[challenge.sender useCredential:cre forAuthenticationChallenge:challenge];

}

}

(2) 看看你的网址  是不是没有添加http:// 前缀

3. code 3840

一般是 JSON格式错误, 就是后台返回的不是JSON格式的数据, 建议

manager.responseSerializer = [AFHTTPResponseSerializer serializer]; (填上这个, responseObject不会解析成JSON的了, 而是原始NSData类型的了

AFN 2.6 code报错总结的更多相关文章

  1. VS Code报错Module 'xx' has no 'xx' member pylint(no-member)解决办法

    pylint是vscode的python语法检查器,pylint是静态检查,在用第三方库的时候有些成员只有在运行代码的时候才会被建立,它就找不到成员,在设置(settings.json)里添加 &qu ...

  2. AFN Post请求,报错400(code:-1011)

    解决方法: 声明请求的参数格式是json, post的数据格式还是传字典. 声明代码: AFHTTPSessionManager *manager = [AFHTTPSessionManager ma ...

  3. Visual Studio Code | 报错 command 'markdown.extension.onBackspaceKey' not found

    背景 今天使用Visual Strudio Code想用键盘Back去删除一些字符,发现报如下错误: command 'markdown.extension.onBackspaceKey' not f ...

  4. Maven-008-Nexus 私服部署发布报错 Failed to deploy artifacts: Failed to transfer file: ... Return code is: 4XX, ReasonPhrase: ... 解决方案

    我在部署构件至 maven nexus 私服时,有时会出现 Failed to deploy artifacts: Failed to transfer file: ... Return code i ...

  5. Cocos Code IDE新建lua工程报错解决方案

    今天想用cocos code IDE新建一个工程,但是控制台报错:Read json file null failed, the reason is:null.我下载的是官方3.5源码,sdk,ndk ...

  6. mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. ->

    mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. -> TEST通过没有报错,但是最终部署到Nexus中时出现错误. 后 ...

  7. Eclipse启动报错Java was started but returned exit code=13

    启动Eclipse的时候报错Java was started but returned exit code=13,这个错误的原因是由于eclipse版本与jdk版本不符导致的,可能你的eclipse是 ...

  8. [问题]编译报错:clang: error: linker command failed with exit code 1及duplicate symbol xxxx in错误解决方法之一

    今天添加了一个新类(包括m,h,xib文件),还没有调用,-编译遇到如下错误,根据错误提示, duplicate symbol param1 in: /Users/xxxx/Library/Devel ...

  9. MySQL 存储过程例子,不能在if else里面用begin end否则会报错Error Code : 1064!

    Error Code : 1064 You have an error in your SQL syntax; check the manual that corresponds to your My ...

随机推荐

  1. 疯狂java学习笔记之面向对象(二) - 成员变量与局部变量

    Java变量按其作用域可分为:成员变量和局部变量.注意:在Java中是没有全局变量这个概念的 一.成员变量: 成员变量是在类中定义的变量,具体可分为类变量与实例变量--有无static修饰 实例变量的 ...

  2. docker不稳定 short running containers with -rm failed to destroy

    正常运行以下命令 sudo docker run --rm busybox echo helloworld /var/log/upstart/docker.log 日志如下: // :: POST / ...

  3. linux 查看机器的cpu,操作系统等命令

    看cpu信息,型号,几核 [root@f3 ~]# cat /proc/cpuinfo | grep name | cut -f2 -d:| uniq -c 16 Intel(R) Xeon(R) C ...

  4. gulp-nodemon 和 gulp-livereload 配置

    一.gulp 安装 1. 全局安装: npm install -g gulp 2. 安装在项目开发环境: npm install gulp --save-dev 二.gulp-nodemon 和 gu ...

  5. 在ScrollView下加入的组件,不能自动扩展到屏幕高度

    ScrollView中的组件设置android:layout_height="fill_parent"不起作用的解决办法 在ScrollView中添加一个android:fillV ...

  6. ACM 房间安排

    房间安排 时间限制:3000 ms  |  内存限制:65535 KB 难度:2   描述 2010年上海世界博览会(Expo2010),是第41届世界博览会.于2010年5月1日至10月31日期间, ...

  7. Linux分区练习(1)

    1.作业描述: 4个主分区. 具体实现过程: 打开Linux,在终端中输入:fdisk -uc /dev/sda 可以查看到                   :Command (m for hel ...

  8. CentOS上使用sysstat做系统监控测试

    先安装sysstat yum -y install systat 然后,再改一下任务计划 [root@localhost sa]# cat /etc/cron.d/sysstat # Run syst ...

  9. JQuery+Ajax制作省市联动

    $(document).ready(function () { $("#Province").append("<option value=''>" ...

  10. [CareerCup] 16.3 Dining Philosophers 哲学家聚餐问题

    16.3 In the famous dining philosophers problem, a bunch of philosophers are sitting around a circula ...