Skip to content

Instantly share code, notes, and snippets.

@candostdagdeviren
Created December 3, 2018 12:34
Show Gist options
  • Save candostdagdeviren/ea202e406efdb936e1b7da82bfb4d74d to your computer and use it in GitHub Desktop.
Save candostdagdeviren/ea202e406efdb936e1b7da82bfb4d74d to your computer and use it in GitHub Desktop.
Swift Post Testability Example Code
class FileOpener {
let application: UIApplication
init(application: UIApplication = UIApplication.shared) {
self.application = application
}
func open(identifier: String) {
guard let url = URL(string: "iosappscheme://open?id=\(identifier)") else {
debugPrint("Failed to load URL")
return
}
if application.canOpenURL(url) {
application.open(url, options: [:], completionHandler: nil)
} else {
debugPrint("Failed to open URL")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment