我想使用 macOS 应用程序中的特定 URL 打开 Chrome。
我正在尝试这样的操作,但不幸的是它不起作用。Chrome 已打开,但未使用给定的 URL 字符串。
let configuration = NSWorkspace.OpenConfiguration()
configuration.arguments = [url.absoluteString]
let appUrl = URL(fileURLWithPath: "/Applications/Google Chrome.app")
NSWorkspace.shared.openApplication(at: appUrl,
configuration: configuration,
completionHandler: nil)
Run Code Online (Sandbox Code Playgroud)
open()在这种情况下对我没有帮助,因为我不想打开标准浏览器。
非常感谢帮助!
我解决了。
NSWorkspace.shared.open([url],
withApplicationAt: URL(fileURLWithPath: "/Applications/Google Chrome.app"),
configuration: configuration)
Run Code Online (Sandbox Code Playgroud)
成功了
| 归档时间: |
|
| 查看次数: |
1403 次 |
| 最近记录: |