Shane O'Seasnain Shane O'Seasnain - 2 months ago 77
Swift Question

how to open an URL in Swift3

openURL
has been deprecated in Swift3. Can anyone provide some examples of how the replacement
openURL:options:completionHandler:
works when trying to open an url?

Answer

All you need is:

let url = URL(string: "http://www.google.com")!
if #available(iOS 10.0, *) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
} else {
    UIApplication.shared.openURL(url)
}
Comments