NSData cannot retrive image from internet anymore [duplicate]

Deadly 提交于 2019-12-02 09:48:13
Gandalf

This is an issue related to ATS(App Transport Security Protocol) changes made by Apple in iOS 9. By default iOS9 disregard communication with http protocol. Your URL should be https. However you can include exception for specific domains in your app or you can allow all http communication to be allowed from within your app.
Check the Documentation for full details.

To Allow all http domains from your application, you should add

<key>NSAppTransportSecurity</key>                                                                                                                                                                                                                                       
  <dict>                                                                                                                                                                                                                                                                  
      <key>NSAllowsArbitraryLoads</key>                                                                                                                                                                                                                                   
      <true/>                                                                                                                                                                                                                                                             
  </dict> 

But as Apple has recommended these new settings, you should chose to add exception for this specific domain in your app rather than allowing all http domains. Check this thread to achieve this.

With iOS 9 you can't call an HTTP anymore because the ATS (App Transport Security) calls should be HTTPS. To work with HTTP links, you should insert the following key in the info.plist file to disable the ATS:

<key>NSAppTransportSecurity</key>
     <dict>
          <key>NSAllowsArbitraryLoads</key><true/>
     </dict>

create a new voice in the info.plist file "NSAppTransportSecurity" like dict. insert in it the key "NSAllowsArbitraryLoads" like boolean and set to YES

;-)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!