Xcode 7请求网络报错
Error Domain=kCFErrorDomainCFNetwork 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)
要求App内访问的网络必须使用HTTPS
协议。我们公司使用的是http协议;
解决方法:
- 在Info.plist中添加
NSAppTransportSecurity
类型Dictionary
。 - 在
NSAppTransportSecurity
下添加NSAllowsArbitraryLoads
类型Boolean
,值设为YES
如图: