iOS - NSURLConnection finished with error - code -1002
网络请求会异常,比如报错:Error domain: @"NSURLErrorDomain" - code: 在回调的地方打一个断点,然后用命令行查看下什么错误: po error
当错误是:**[Error Domain=NSURLErrorDomain Code=- ] "unsupported URL" **
*Error Domain=NSURLErrorDomain Code=- "unsupported URL" UserInfo={NSLocalizedDescription=unsupported URL, NSUnderlyingError=0x7fa9b1d06120 {Error Domain=kCFErrorDomainCFNetwork Code=- "(null)"}} * 的时候是url编码问题,处理一下URL编码就好了 我这边是后台返回的拼接的接口多了“/”,导致统一的域名格式不统一
http://gwtest.opg-iot.com:8000//api-sdeventApplication/images/handle/event_result/event_result_beimg_20190522093224_0.jpeg?Authenticator=eyJhbGciOiJIUzI1NiJ9.eyJyZWFsTmFtZSI6bnVsbCwibG9naW5OYW1lIjoiU0Q3MzkzIiwidXNlclR5cGUiOiIxIiwicGxhdGZvcm1JZCI6MTAsImV4cCI6MTU1OTA5MzkxOSwidXNlcklkIjo3MzkzfQ.KieGb8LUsgpvn9BU9jjSiNSNn12irclYKiPH_s0Uqgk
处理方法:
iOS 要用utf8转码:
urlString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
iOS 以后要用这个方法:
urlString = [urlString stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet characterSetWithCharactersInString:@"#%^{}\"[]|\\<> "].invertedSet];
iOS - NSURLConnection finished with error - code -1002的更多相关文章
- 解决NSURLConnection finished with error - code -1100错误
更新到xcode9以后,拖进工程中一个html文件,webview加载这个文件,xcode一直抛出 NSURLConnection finished with error - code -1100异常 ...
- WebView loadRequest请求错误"NSURLConnection finished with error - code -1022"
执行下面代码 [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www ...
- 解决 React-Native mac 运行报错 error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65. To debug build logs further, consider building your app with Xcode.app, by ope
React-Native 开发的项目,Android 方面没有任何问题,IOS 就是无法跑起来,报错信息如下: mac 10.14.4 xcode 10.2.1 error Failed to bui ...
- IOS真机调试找不到设备:ERROR: Could not connect to lockdownd, error code -[x]
报错信息: Could not connect to lockdownd, error code -3 解决方法:修改var/db/lockdown文件夹的读写权限 在终端找到文件夹cd var/db ...
- Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl -xe" for details
thinkphp 在Apache上配置启用伪静态,重启Apache1 restart 竟然失败了,报错 Job for httpd.service failed because the control ...
- 不受支持的URL Statue Code 1002
1. 错误提示: Error description=Error Domain=NSURLErrorDomain Code=-1002 "unsupported URL" User ...
- Android-AndroidStudio-AVD启动不了-emulator: Process finished with exit code 1
注意:解决此错误目前只针对Windows系统的电脑: 1.AndroidStudio-->AVDManager(Create Virtual Device): 2.提示AVD启动不了,同时Eve ...
- ios错误码:NSError对象.code
1. URL Loading System Error Codes These values are returned as the error code property of an NSError ...
- ORA-00600: internal error code, arguments: [2662], [0], [1106971], [0], [1107731], [12583040]
今天是2014-06-06,在进行数据库恢复的时候出现了一个久违的ora-600 [2662]错误.特整理例如以下: 问题描写叙述: system及数据文件误删,採用恢复数据文件的方式将数据库恢复到開 ...
随机推荐
- php备忘录模式(memento pattern)
晚上刷起来. <?php /* The memento pattern provides the object restore functionality. Implementation is ...
- php的类使用样例
这个demo.差不多php的类的主要知识点都用到了. public,private关键字, namespace,use命令空间, require导入, interface复用, abstract抽象类 ...
- Beyond Compare设置自定义过滤
Beyond Compare是一款优秀的专业级文件比较软件,利用它可以快速比较出文件之间的差异,以便于修改.整合.其中较强大的功能之一就是文件夹比较,面对海量的子文件夹以及文件,Beyond Comp ...
- html中定位详解
首先,我们来讨论一下html中共有几种定位方式:静态定位(static),相对定位(relative),绝对定位(absolute,fixed).其中fixed又叫固定定位,它是属于绝对定位的一种,但 ...
- BZOJ-1042:硬币购物(背包+容斥)
题意:硬币购物一共有4种硬币.面值分别为c1,c2,c3,c4.某人去商店买东西,去了tot次.每次带di枚ci硬币,买si的价值的东西.请问每次有多少种付款方法. 思路:这么老的题,居然今天才做到. ...
- Mac下用java代码调用adb命令时出错
原本我直接这样写: Process process=Runtime.getRuntime().exec("adb devices"); 但是运行时出错: java.io.IOExc ...
- 关于defer.promise.then 异步的一个疑问 | 用柯里化做promise | 用递归做promise
疑问:感觉会报错,因为执行到defer.promise.then这时候还没到defer.resolve,因为异步读文件,总归会慢 解答:先执行defer.promise.then,是给callback ...
- abp radio表单元素 消失了
框架将原本的元素都隐藏掉了,取而代之的是根据label定义了自己的样式,如下: [type="radio"]:not(:checked)+label { padding-le ...
- Codeforces Round #603 (Div. 2) E. Editor(线段树)
链接: https://codeforces.com/contest/1263/problem/E 题意: The development of a text editor is a hard pro ...
- 用插件maven-surefire-report-plugin生成html格式测试报告
在默认情况下,执行maven test/maven package/maven install命令时会在target/surefire-reports目录下生成txt和xml格式的输出信息. 其实ma ...