Error Domain=NSURLErrorDomain Code=-1022 “The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.” UserInfo={NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.


由于苹果引入的一项隐私保护功能ATS(App Transport Security),ATS屏蔽了HTTP明文传输协议资源加载,就是因为http明文传输协议不安全,所以要求连接必须改成更安全的HTTPS协议。在 iOS 9 和 OSX 10.11中,默认情况下非HTTPS的网络访问是被禁止的。如果使用HTTP协议连接,会抛出一个错误。在Info.plist添加类型为Dictionary的NSAppTransportSecurity 并且将类型为 Boolean的NSAllowsArbitraryLoads 设置为 YES 即可来禁用 ATS,从而继续使用HTTP明文传输。


解决方法如下:

在info.plist里面增加
App Transport Security Settings 属性
再在此属性内添加 Allow Arbitrary Loads ,设置值为YES。

如下图:

ios请允许cookie存储 允许我的请求_swift

#言语逻辑若有不当处,望指正!!!!!!感谢 >_<