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的网址
在 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];
}
}