ref:http://blog.csdn.net/nyh1006/article/details/25068255javascript
一、錯誤信息:Error:Error Domain=AFNetworkingErrorDomain Code=-1016 "Request failed: unacceptable content-type: text/html" UserInfo=0x16dcec00 {NSErrorFailingURLKey=http://www.weather.com.cn/data/sk/101110101.html, AFNetworkingOperationFailingURLResponseErrorKey=<NSHTTPURLResponse: 0x16d5deb0> { URL: http://www.weather.com.cn/data/sk/101110101.html } { status code: 200, headers {
Connection = "keep-alive";
"Content-Encoding" = gzip;
"Content-Type" = "text/html; charset=utf-8";
Date = "Mon, 05 May 2014 09:40:27 GMT";
Server = "Apache/2.2.0";
"Transfer-Encoding" = Identity;
} }, NSLocalizedDescription=Request failed: unacceptable content-type: text/html}html
緣由:java
AFNetworking 默認不支持text/htmlgit
AFURLResponseSerialization.m 源碼 -> self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript", nil]; github
解決辦法:json
1)在做者源代碼處添加 @"text/html" 。app
2)在本身的代碼處加上這句代碼:spa
manager.responseSerializer.acceptableContentTypes = [NSSet setWithObject:@"text/html"];.net
缺什麼類型就填那種類型,好比我是 text/plaincode
參考的資料:
http://www.cocoachina.com/bbs/simple/?t176000.html
http://www.cocoachina.com/ask/questions/show/108598
https://github.com/AFNetworking/AFNetworking/blob/master/README.md