在做一个网络应用时,解析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
Paste_Image.png
不过从苹果官方目前发布出来的消息上看, 在 2017 年一月份开始,就不再允许开发者打开 NSAllowsArbitraryLoads 设置了。
本文介绍了解决Xcode中因禁用HTTP传输导致JSON解析错误的方法。通过在Info.plist文件中设置AppTransportSecuritySettings及AllowArbitraryLoads为YES来解决此问题。但注意苹果已限制此设置。
787

被折叠的 条评论
为什么被折叠?



