I'm creating an app that uses WKWebView. Whenever a user clicks on a link in that webview, I want the link to open up in safari instead of inside the webview. I'm really new at coding, so please make it as easy as possible. I just need the code I need to add. Here's the code bellow:
import UIKit
import WebKit
class FirstViewController: UIViewController {
@IBOutlet var containerView: UIView! = nil
var webView: WKWebView?
override func loadView() {
super.loadView()
self.webView = WKWebView()
self.view = self.webView!
}
override func viewDidLoad() {
super.viewDidLoad()
var url = NSURL(string:"http://www.example.com/")
var req = NSURLRequest(url:url as! URL)
self.webView!.load(req as URLRequest)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
I'm using Xcode 8 and Swift 3