zoukankan      html  css  js  c++  java
  • 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,所以要加上这段代码:
  • 相关阅读:
    使用Power Shell 拉取项目源代码
    C# 读取excel数据到datatable
    C# 导出datatable数据到excel
    redis过一段时间连接不上
    windows10 docker volume
    通过端口查询到应用
    centos清理磁盘
    maven镜像加速
    IDEA常用插件
    java开发常用软件
  • 原文地址:https://www.cnblogs.com/jackyshan/p/5398958.html
Copyright © 2011-2022 走看看