Xcode7 网络请求报错:The resource could not be loaded because the App Transport Security policy requires th

这些天打开公司的应用,总是网络请求报错。之前没有细看报错信息,还以为是后台把服务停了呢。后来询问安卓的同事,他们的数据没问题。这才仔细的看了下报错信息:

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSUnderlyingError=0x7fbbb9dd4dc0 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection." UserInfo={NSErrorFailingURLStringKey=http://app.dajike.com/Jbbs/call, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection., NSErrorFailingURLKey=http://app.dajike.com/Jbbs/call}}, NSErrorFailingURLStringKey=http://app.dajike.com/Jbbs/call, NSErrorFailingURLKey=http://app.dajike.com/Jbbs/call, NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}


这是由于iOS9添加了新特性:App Transport Security (ATS),最近刚刚升级了xcode到版本七;

解决办法:

  1. 在Info.plist中添加NSAppTransportSecurity类型Dictionary
  2. NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值