[ iOS ] AFNetworking API text/html 殺蟲劑-1016

錯誤訊息

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

這個錯誤訊息真讓人苦惱!該如何讓他永遠消失呢?? 這問題是因為在acceptableContentTypes 沒有支援 text/html

解決方法

開啟 Serilization->AFURLResponseSerialization.m

原本的樣子

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

新增 text/html

    self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/json", @"text/javascript",@"text/html", nil];

新增後保證滅絕害蟲

Polo

Having being a full stack engineer. His interests in Node.js, ARM mbed, IoT solutions, iOS Contact us : [email protected]

ALL RIGHTS RESERVED. COPYRIGHT © 2016. Designed and Coded by Makee.io