ATS

来源:互联网 发布:易知北京投资有限公司 编辑:程序博客网 时间:2024/06/11 03:54

开发过程中遇到的小坑:
即使用Xcode7编写iOS9应用时,如果获取http://数据时,会有如下错误提示:

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.

原因分析:
从iOS9起,新特性要求App访问网络请求,要采用 HTTPS 协议。

如果仍想要使用HTTP协议,有如下两种解决办法:
(1)在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ; 展开该选项,即在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean,值设为 YES;
(2)使用文本编辑器打开Info.plist文件,然后添加如下内容:

<key>NSAppTransportSecurity</key><dict>    <key>NSAllowsArbitraryLoads</key>    <true/></dict>
0 0