用Xcode 7--Xcode 8经常新建一个工程用到 URL 发送请求时,报下面的错
“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”
新特性要求App内访问网络请求,要采用 HTTPS 协议。
由于获取的网络地址都是HTTP协议,最终找到以下两种解决办法:
a.在Info.plist中添加 NSAppTransportSecurity 类型 Dictionary ;
在 NSAppTransportSecurity 下添加 NSAllowsArbitraryLoads 类型Boolean ,值设为 YES;
b.单击Info.plist-->open as-->Sourse Code -->添加以下一段代码即可:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>