AFN 2.6 code报错总结
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报错总结的更多相关文章
- VS Code报错Module 'xx' has no 'xx' member pylint(no-member)解决办法
pylint是vscode的python语法检查器,pylint是静态检查,在用第三方库的时候有些成员只有在运行代码的时候才会被建立,它就找不到成员,在设置(settings.json)里添加 &qu ...
- AFN Post请求,报错400(code:-1011)
解决方法: 声明请求的参数格式是json, post的数据格式还是传字典. 声明代码: AFHTTPSessionManager *manager = [AFHTTPSessionManager ma ...
- Visual Studio Code | 报错 command 'markdown.extension.onBackspaceKey' not found
背景 今天使用Visual Strudio Code想用键盘Back去删除一些字符,发现报如下错误: command 'markdown.extension.onBackspaceKey' not f ...
- 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 ...
- Cocos Code IDE新建lua工程报错解决方案
今天想用cocos code IDE新建一个工程,但是控制台报错:Read json file null failed, the reason is:null.我下载的是官方3.5源码,sdk,ndk ...
- mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. ->
mvn deploy 报错:Return code is: 400, ReasonPhrase: Bad Request. -> TEST通过没有报错,但是最终部署到Nexus中时出现错误. 后 ...
- Eclipse启动报错Java was started but returned exit code=13
启动Eclipse的时候报错Java was started but returned exit code=13,这个错误的原因是由于eclipse版本与jdk版本不符导致的,可能你的eclipse是 ...
- [问题]编译报错:clang: error: linker command failed with exit code 1及duplicate symbol xxxx in错误解决方法之一
今天添加了一个新类(包括m,h,xib文件),还没有调用,-编译遇到如下错误,根据错误提示, duplicate symbol param1 in: /Users/xxxx/Library/Devel ...
- 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 ...
随机推荐
- Java String类的常用方法
String(byte[ ] bytes):通过byte数组构造字符串对象. String(char[ ] value):通过char数组构造字符串对象. String(Sting original) ...
- 转载:robotium typeText与enterText区别
solo.typeText和solo.enterText方法都可以对EditeText进行测试,达到的测试目的是一样的.存在几点不同: 1.实现上,typeText方法是robotium框架调用系统I ...
- Wordcount on YARN 一个MapReduce示例
Hadoop YARN版本:2.2.0 关于hadoop yarn的环境搭建可以参考这篇博文:Hadoop 2.0安装以及不停集群加datanode hadoop hdfs yarn伪分布式运行,有如 ...
- WPF中ComboBox用法
The ComboBox control is in many ways like the ListBox control, but takes up a lot less space, becaus ...
- BZOJ2082 : [Poi2010]Divine divisor
将所有数分解质因数,那么第一问就是求指数的最大值,第二问就是$2^{指数最大的质数个数}-1$. 首先将$10^6$以内的质因数全部找到,那么剩下部分的因子$>10^6$,且只有3种情况: 1. ...
- BZOJ3145 : [Feyat cup 1.5]Str
如果不存在模糊点,那么答案就是两个串的最长公共子串. 如果模糊点是某个串的开头或者结尾,那么可以暴力枚举另一个串中的某个前后缀更新答案. 否则,假设模糊点在第一个串里是$i$,在第二个串里是$j$,那 ...
- 只有火狐识别的css
写在css里写只有火狐可以识别,其他浏览器不行. 就算写在@media only screen and (min-width: 960px) and (max-width: 1200px){ 里面也行 ...
- 你可能不再需要Underscore
过去几年像 Underscore 和 lodash 等库进入许多JavaScript程序员的工具函数中.虽然这些工具库可以使你的代码写起来更容易,但是他们不一定使代码更简单或更容易理解. 各种工具函数 ...
- Scheduled Projects
Plans as at 10/03/15 ASB --------> Li ...
- ACM The Famous Clock
The Famous Clock 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 Mr. B, Mr. G and Mr. M are now in Warsaw, ...