AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

原因:iOS9以后,苹果把原http协议改成了https协议,所以不能直接在http协议下GET/POST

解决方案之一:

直接编辑工程文件下的Info.plist文件,加入以下代码

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

如图所示:

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

解决方案之二:

a.在Xcode里选中info.plist,点击右边的information Property List 后边的加号

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

b.写入App Transport Security Settings然后回车,先点击左侧展开箭头,再点右侧加号,Allow Arbitrary Loads 已经自动生成,直接回车。

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

c.需要把默认的值改成YES

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

其实效果是一样的,打开info.plist文件,发现方案一中的文字已经自动添加

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires the use of a secure connection" 解决办法

<完>

 
 http://www.cnblogs.com/36bian/p/5237138.html
上一篇:C语言qsort()函数对-2147483648、2147483648溢出报错


下一篇:[Acwing | 蓝桥杯] 1236. 递增三元组 二分