The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

Xcode 升级到7.3beta版后,做http的网络访问的时候会报错:
error------ Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}

网络搜索之后才知道,Xcode9引入了新特性ATS,要求app访问的网络必须使用HTTPS协议。如果想要继续访问http网页,需要在info.plist文件中添加NSAppTransportSecurity关键字,其类型为Dictionary,在它下面添加NSAllowsArbitraryLoads类型Boolean,值设为YES。这样就可以接着访问http网页啦~~

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容