Skip to content

Instantly share code, notes, and snippets.

@strzempa
Created October 11, 2019 05:24
Show Gist options
  • Save strzempa/694cdd62e767a164d0a8497fd0320c07 to your computer and use it in GitHub Desktop.
Save strzempa/694cdd62e767a164d0a8497fd0320c07 to your computer and use it in GitHub Desktop.
import Foundation
public extension UIApplication {
class func tryURL(_ urls: [String]) {
let application = UIApplication.shared
urls.forEach { urlString in
guard let url = URL(string: urlString) else {
Logger.error?.message("Cannot make url from: \(urlString)")
return
}
if application.canOpenURL(url) {
application.open(url)
return
} else {
Logger.error?.message("Cannot open url: \(url)")
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment