升级Xcode7.1 网络问题

来源:互联网 发布:python agent开发 编辑:程序博客网 时间:2024/05/19 16:22

报错: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.“

原因:iOS9引入了新特性App Transport Security (ATS)

解决问题只是把ATS禁用了,不是最好的方法。

info.plist: 加入

  1. 添加NSAppTransportSecurity类型Dictionary
  2. NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

代码:<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/> 
  </dict>

打开info.plist是这样的:




0 0
原创粉丝点击