iOS9https设置info.plist
Xcode 7.0也就是iOS9.0中开发要求App内访问的网络必须使用HTTPS协议。那么我们公司没用采用https怎么办?如果发现网络请求失败,Xcode后台报错信息为:
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
(大概意思就是:资源数据不能被下载,因为APP传输安全策略需要采用安全的连接方式)。
解决方法:
在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
找到info.plist,注意不是测试文件里面的plist哦。
操作见GIF图。千言万语,不如一张图。
另外博主维护一个iOS开发技术支持群:479259423,进群必须改名,群名片格式:城市-iOS-名字,例如广州-iOS-文明。