Abrir link específico no Safari a partir do UIWebView

eu tenho umUIWebView que carrega um arquivo index.html local.

No entanto, tenho um link externo neste arquivo html que gostaria de abrir no Safari em vez de internamente noUIWebView.

Abrir um link no safari de digamos umUIButton foi bastante simples:

UIApplication.sharedApplication().openURL(NSURL(string: "http://www.stackoverflow.com"))

Abrir o aplicativo Instagram a partir de um link externo também funciona como um encanto.

<a href="instagram://media?id=434784289393782000_15903882">instagram://media?id=434784289393782000_15903882</a>

Então, meu primeiro pensamento foi fazer algo assim:

<a href="safari://stackoverflow.com">Open in Safari</a>

No entanto, isso não parece funcionar, então eu li algo sobre como usarwebView:shouldStartLoadWithRequest:navigationType:

Mas todo mundo que conseguiu abrir um link externo no Safari está escrevendo no Obj-C, com o qual não estou muito familiarizado como estou escrevendo no Swift.

Atualize com o Swift Code:

import UIKit

class AccessoriesViewController: UIViewController, UIWebViewDelegate {


    @IBOutlet weak var webView:UIWebView!

    override func viewDidLoad() {
        super.viewDidLoad()


        if let url = NSBundle.mainBundle().URLForResource("accessories", withExtension: "html") {
            webView.loadRequest(NSURLRequest(URL: url))
        }



    }
    override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return UIStatusBarStyle.LightContent;
    }

    func webView(webView: UIWebView, shouldStartLoadWithRequest request: NSURLRequest, navigationType: UIWebViewNavigationType) -> Bool {
        if let url = request.URL where navigationType == UIWebViewNavigationType.LinkClicked {
            UIApplication.sharedApplication().openURL(url)
            return false
        }
        return true
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

questionAnswers(1)

yourAnswerToTheQuestion