前两天升级了Xcode7.0,发现用模拟器运行某些须要网络访问的项目的时候会报错,具体以下:网络
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.ui
缘由以下:spa
Xcode7.0要求App内访问的网络必须使用https协议,而当前使用的是 http协议。3d
后来从网上找到的解决方法是这样的:code
在Info.plist中添加NSAppTransportSecurity
类型Dictionary
。blog
在NSAppTransportSecurity
下添加NSAllowsArbitraryLoads
类型Boolean
,值设为YES。
it
具体实现方法以下:io
1.项目目录中找到Info.plist文件并打开require
2.在打开的Info.plist文件中点击“+”,添加新的字典,并命名为NSAppTransportSecurity方法
3.打开NSAppTransportSecurity并添加NSAllowsArbitraryLoads
类型Boolean
,值设为YES
完成这三步以后回到项目,网络就能够正常访问了。