>  기사  >  웹 프론트엔드  >  修改AFNetworking源文件可接收text/plain和text/html的方法_html/css_WEB-ITnose

修改AFNetworking源文件可接收text/plain和text/html的方法_html/css_WEB-ITnose

WBOY
WBOY원래의
2016-06-24 11:45:31828검색

 在使用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 =[NSSetsetWithObjects:@"application/json",@"text/json",@"text/javascript",@"text/html",nil];

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



성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.