关于AFNetworking的一种错误!

今天用 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
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值