AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires

原因: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

解决方案之二:

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

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires

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

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires

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

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires

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

AFNetworking 提示"The resource could not be loaded because the App Transport Security policy requires