你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS—修改AFNetworking源文件可接收text/plain的方法

iOS—修改AFNetworking源文件可接收text/plain的方法

編輯:IOS開發綜合

iOS—修改AFNetworking源文件可接收text/plain的方法

在使用AFNetworking的時候可能會碰到下面的錯誤:

{ status code: 200, headers {

"Content-Length" = 14;

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

Date = "Thu, 22 May 2014 10:37:50 GMT";

Server = "Apache-Coyote/1.1";

"Set-Cookie" ="JSESSIONID=C0DFED60A154557F8386E62AB2A066CE; Path=/FHJRDT";

} }, NSLocalizedDescription=Request failed:unacceptable content-type: text/plain}

此時需要修改AFNetworking可接收的Content-Type,前往AFNetworking源代碼目錄找到AFURLResponseSerialization.m文件將裡面的代碼:

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

修改為:

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

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

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved