我想在浏览器中打开一个url,但是我得到了以下错误:
未解析标识符NSWorkspace的使用
我的代码:
if let url = URL(string: "https://www.google.com"), NSWorkspace.shared().open(url) {
print("default browser was successfully opened")
}发布于 2017-04-01 14:18:14
您正在尝试为macOS代码添加用于iOS的代码。在为iOS编写代码时,必须使用UIApplication.shared
if let url = URL(string: "https://google.com"), UIApplication.shared.canOpenURL(url) {
UIApplication.shared.open(url)
}https://stackoverflow.com/questions/43157793
复制相似问题