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>

如图所示:

解决方案之二:

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

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

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

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

 <完>

 
 http://www.cnblogs.com/36bian/p/5237138.html
原文地址:https://www.cnblogs.com/lixiuran/p/5742722.html