OC Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html"

2015-11-16 10:39:17.235 PullDemo[338:60b] Application windows are expected to have a root view controller at the end of application launch

2015-11-16 10:39:17.500 PullDemo[338:60b] Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x8d3a640 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x8d559f0> { URL: http://www.baidu.com/ } { status code: 200, headers {

    "Cache-Control" = "no-cache";

    Connection = "Keep-Alive";

    "Content-Encoding" = gzip;

    "Content-Length" = 3174;

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

    Date = "Mon, 16 Nov 2015 02:39:17 GMT";

    Server = apache;

    "Set-Cookie" = "H_WISE_SIDS=100037; path=/; domain=.baidu.com";

    traceid = 144764155704053939308606070253431897318;

} }, NSErrorFailingURLKey=http://www.baidu.com/, NSLocalizedDescription=Request failed: unacceptable content-type: text/html,

afnetworking的这个错误大家不陌生吧,解决方法

AFURLResponseSerialization.m的223行加上@"text/html"就可以解决了

或者请求的时候添加一句代码:

manager.responseSerializer.acceptableContentTypes = [NSSet setWithObjects:@"application/json",@"text/json",@"text/html",@"image/png",@"text/html;charset=UTF-8",@"text/plain", nil];
原文地址:https://www.cnblogs.com/hualuoshuijia/p/4971535.html