在做一个网络应用时,解析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可解决:
- 添加App Transport Security Settings,类型是Dictionary
- 在App Transport Security Settings添加Allow Arbitrary Loads,类型是Boolean,值是YES
不过从苹果官方目前发布出来的消息上看, 在 2017 年一月份开始,就不再允许开发者打开 NSAllowsArbitraryLoads 设置了。