Swift2.0 HTTP request not working

Hi Stackoverflow,

I keep getting this error after moving my quick application to Swift2.0:

App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app Info.plist file. The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. 

And I looked at the following link https://forums.developer.apple.com/thread/5835

and added the following code to my info.plist

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

And this still does not work, who has an alternative solution?

+6
source share
1 answer

It is not a Swift 2.0 actually issues iOS 9.0 , where iOS 9.0 causes web traffic to go over https , setting the flag below allows http traffic.

You must set the NSAllowsArbitraryLoads key to YES in the NSAppTransportSecurity dictionary in your .plist file. Hope this helps!

enter image description here

+8
source

All Articles