AFNetwork 2.5 修正版

来源:互联网 发布:海南省最新网络诈骗案 编辑:程序博客网 时间:2024/05/16 14:55

修正这位大神的demo,因为他不能够解析某些格式的数据,比如text/plain等。

http://blog.csdn.net/daiyelang/article/details/38434023

 在使用AFNetworking的时候可能会碰到下面的错误:

    { status code: 200, headers {

    "Content-Length" = 14;

    "Content-Type" = "text/plain;charset=utf-8";

    Date = "Thu, 22 May 2014 10:37:50 GMT";

    Server = "Apache-Coyote/1.1";

    "Set-Cookie" ="JSESSIONID=C0DFED60A154557F8386E62AB2A066CE; Path=/FHJRDT";

    } }, NSLocalizedDescription=Request failed:unacceptable content-type: text/plain}

    此时需要修改AFNetworking可接收的Content-Type,前往AFNetworking源代码目录找到AFURLResponseSerialization.m文件将里面的代码:

    self.acceptableContentTypes =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",nil];

    修改为:

    self.acceptableContentTypes = [[NSSetalloc]initWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html",@"text/plain",nil];

修正后的demo下载地址:http://download.csdn.net/detail/robinson_911/8824871
0 0