在利用AFN进行数据解析时出现返回数据为
<7b227374 61747573 223a302c 226d6573 73616765 223a22e6 82a8e79a 84e6898b e69cbae5 8fb7e5b7 b2e7bb8f e6b3a8e5 868c222c 22646174 61223a6e 756c6c7d>
的类型,这种的数据,responseObject 为 _NSInlineData 类型。 解决办法如下:
将:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFHTTPResponseSerializer new]; manager.responseSerializer.acceptableContentTypes = [NSSetsetWithObjects:@"application/json",@"text/html",@"text/javascript",@"text/json",@"text/plain", nil];
改为:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager]; manager.responseSerializer = [AFJSONResponseSerializer new]; manager.responseSerializer.acceptableContentTypes = [NSSetsetWithObjects:@"application/json",@"text/html",@"text/javascript",@"text/json",@"text/plain", nil];
即:AFHTTPResponseSerializer 转换为 AFJSONResponseSerializer ;
问题即可解决。