【iOS开发】棘手BUG
2016-05-30 13:21
369 查看
BUG-1:
解决方法:changed the value of the “Compiler for C/C++/Objective-C” to Default Compiler.
BUG-2:
AFNetworking 错误 Request failed: unacceptable content-type: text/plain. 网络请求api获取数据的时候发现以下错误: error: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo=0x17d0ccb0 {NSErrorFailingURLKey=http://192.168.1.34:8080/SpringREST/api/driverLogin/123/abc, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17d14480> { URL:http://192.168.1.34:8080/SpringREST/api/driverLogin/123/abc } { status code: 200, headers { "Content-Length" = 156; Date = "Thu, 16 Apr 2015 06:29:34 GMT"; Server = "Apache-Coyote/1.1"; } }, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain}error: Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/plain" UserInfo=0x17d0ccb0 {NSErrorFailingURLKey=http://192.168.1.34:8080/SpringREST/api/driverLogin/123/abc, com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x17d14480> { URL:http://192.168.1.34:8080/SpringREST/api/driverLogin/123/abc } { status code: 200, headers { "Content-Length" = 156; Date = "Thu, 16 Apr 2015 06:29:34 GMT"; Server = "Apache-Coyote/1.1"; } }, NSLocalizedDescription=Request failed: unacceptable content-type: text/plain}
解决方案:
需要在AFNetWorking的源文件AFURLResponseSerialization.m中添加以下绿色部分代码
相关代码:
- (instancetype)init { self = [super init]; if (!self) { return nil; } self.acceptableContentTypes = [NSSet setWithObjects:@"application/json", @"text/html", @"text/json", @"text/javascript",@"text/plain", nil]; return self; }
BUG-3:AFN(400)错误
传递的参数不对
BUG-4:AFN(404)错误
json 序列化问题404错应该是服务器不可到达造成的
manager.responseSerializer = [AFJSONResponseSerializer serializer]; manager.requestSerializer = [AFHTTPRequestSerializer serializer];
BUG-5:AFN(500)错误
HTTP Status 500(服务器内部错误)服务器遇到错误,无法完成请求。
相关文章推荐
- IOS 时间和时间戳之间转化
- iOS Xcode报错exc_bad access code=exc_1386_gpflt处理
- 动态计算文本高度
- IOS动画(Core Animation)总结 (参考多方文章)
- IOS动画(Core Animation)总结 (参考多方文章)
- iOS MKMapView 基础知识
- RN填坑----iOS给控件设置背景图片无效
- 【iOS开发】常用宏
- iOS 公开项目
- iOS 多线程篇4—线程间的通信
- iOS支付宝开发总结
- iOS 宏
- iOS原生CIFilter创建二维码
- IOS开发 Xcode7.3不能提示自定义类名问题解决办法
- iOS开发分享之“白名单”
- ios开发try catch使用
- iOS 二维码 2
- iOS 多线程篇3—线程安全
- 正确使用iOS常量(const)、enum以及宏(#define)
- iOS 图形编程总结