常常使用 AFNetworking 在處理與伺服端的 api 溝通,而回傳值是用 Json 格式。
最近遇到伺服端回傳 text/html 的 content-types,而 AFJSONRequestOperation 預設支援的 content-types 為 "text/json", "application/json" or "text/javascript" 這三種。
解決方法為將 text/html 加入支援的 content-types 即可
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
沒有留言:
張貼留言