I would like to open a url in browser but I get this error:
Use of unresolved identifier NSWorkspace
my code:
if let url = URL(string: "https://www.google.com"), NSWorkspace.shared().open(url) {
print("default browser was successfully opened")
}
I would like to open a url in browser but I get this error:
Use of unresolved identifier NSWorkspace
my code:
if let url = URL(string: "https://www.google.com"), NSWorkspace.shared().open(url) {
print("default browser was successfully opened")
}
You are trying to add a code for macOS coding for iOS. When coding for iOS you have to use UIApplication.shared
if let url = URL(string: "https://google.com"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}