• afnetworking NSCocoaErrorDomain Code=3840 解决


    afnetworking json解析出错

    解决方法1

        AFURLResponseSerialization.m
    258行修改
    
    responseString = [responseString stringByReplacingOccurrencesOfString:@"
    " withString:@""];
    responseString = [responseString stringByReplacingOccurrencesOfString:@"
    " withString:@""];
    responseString = [responseString stringByReplacingOccurrencesOfString:@"	" 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,所以要加上这段代码:
  • 相关阅读:
    ORM之F和Q
    ORM查询
    Django
    jQuery基础
    DOM和BOM
    saas baas paas iaas 的理解
    分布式架构的演进过程
    tomcat 配置https 证书
    idea 学习总结
    简单数据库连接池-总结
  • 原文地址:https://www.cnblogs.com/jackyshan/p/5398958.html
Copyright © 2020-2023  润新知