关于AFNetworking的一种错误!

来源:互联网 发布:淘宝100元左右的鼠标 编辑:程序博客网 时间:2024/06/06 09:55

今天用 AFNetworking 的时候不能解析,因为程序根本不往里面走(只到 [ manager  GET … ] 就结束了) 并且有返回错误信息:


//一下是错误信息

Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x7f9003e60c60> { URL: http://api.wap.miercn.com/api/2.0.3/pic_list.php?plat=android&proct=mierapp&versioncode=20150807&apiCode=4&page=1 } { status code: 200, headers {

    Connection = "keep-alive";

    "Content-Encoding" = gzip;

    "Content-Type" = "text/html; charset=UTF-8";

    Date = "Sat, 31 Oct 2015 03:44:25 GMT";

    "Keep-Alive" = "timeout=2";

    Server = "M_cdn";

    "Transfer-Encoding" = Identity;

    Vary = "Accept-Encoding";

    "X-Powered-By" = "PHP/5.6.12";

} }, NSErrorFailingURLKey=http://api.wap.miercn.com/api/2.0.3/pic_list.php?plat=android&proct=mierapp&versioncode=20150807&apiCode=4&page=1, com.alamofire.serialization.response.error.data=<7b226572


====================等等=======================

 30227d5d 7d>, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}


关键原因是:  NSLocalizedDescription=Request failed: unacceptable content-type: text/htm


然后在群里喊了一声,有朋友说是返回值的问题, AFNetworking 默认的返回值是JSON的, 让我在源文件修改一下就好,然后我在源文件(AFNetworking)的其中的  AFURLResponseSerialization.m 文件中,  self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/json", nil];  添加  @“text/html”( 意思就是它缺什么返回值类型,你给他添加上就是 )  目前为止遇到的一种情况

0 0
原创粉丝点击