Swift4 URLをSafariで開く

2017-08-30

// URLをSafariで開く
func openWithSafari(url: URL?) {
    guard let openUrl = url else {
        print("無効なURLです")
        return
    }
    
    if UIApplication.shared.canOpenURL(openUrl as URL) {
        print(openUrl)
        UIApplication.shared.open(openUrl)
    }
}