Unable to view web sites with http… prefix. I can only view https… web sites using iOS simulator / webView in Swift.
Can you advise how I can load say google or apple using http…. Google works ok with https but not with http.
Suggestion in https: - [crashed my app]
Adding the following to your Info.plist will disable ATS
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
MySample code attached:
import UIKit
class ViewController: UIViewController, NSURLSessionDelegate {
@IBOutlet var webView: UIWebView!
@IBAction func doRefresh(AnyObject) {
webView.reload()
}
@IBAction func goBack(AnyObject) {
webView.goBack()
}
@IBAction func goForward(AnyObject) {
webView.goForward()
}
@IBAction func stop(AnyObject) {
webView.stopLoading()
}
override func viewDidLoad() {
super.viewDidLoad()
let url = NSURL(string: "http://google.com")
let request = NSURLRequest(URL: url!)
webView.loadRequest(request)
}
Thanks