zoukankan      html  css  js  c++  java
  • [AFN]AFNetworking错误总结

    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];

        }

    }

  • 相关阅读:
    程序片段--2的乘方
    Set、Map集合、栈、队列
    Map迭代(六种)
    Struts2标签--控制标签
    线性表
    数据结构笔记(1)
    spingMVC问题小结
    《浪潮之巅》十四章笔记
    《浪潮之巅》十三章笔记
    《浪潮之巅》十二章笔记
  • 原文地址:https://www.cnblogs.com/wangqi1221/p/5240258.html
Copyright © 2011-2022 走看看