App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. 报错处理.

在做一个网络应用时,解析json时报错 App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app's Info.plist file. fatal error: unexpectedly found nil while unwrapping an Optional value

报错原因是xcode禁止明文http传输.通过修改info.plist可解决:

  1. 添加App Transport Security Settings,类型是Dictionary
  2. 在App Transport Security Settings添加Allow Arbitrary Loads,类型是Boolean,值是YES
Paste_Image.png

不过从苹果官方目前发布出来的消息上看, 在 2017 年一月份开始,就不再允许开发者打开 NSAllowsArbitraryLoads 设置了。

这里有详细介绍

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容