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
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. 报错处理._第1张图片
Paste_Image.png

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

这里有详细介绍

你可能感兴趣的:(App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. 报错处理.)