gpt4 book ai didi

macos - 通过cocoa应用程序在safari中打开url

转载 作者:行者123 更新时间:2023-12-03 16:02:14 25 4
gpt4 key购买 nike

我想仅通过 Safari 中的应用程序在 Cocoa 中打开 URL。我正在使用:

[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: @"my url"]];

但问题是,如果我的默认浏览器不是 Safari,则该 URL 会在其他浏览器中打开。但我希望我的 URL 只能在 Safari 中打开。请告知解决办法。

谢谢:)

最佳答案

let url = URL(string:"https://twitter.com/intent/tweet")!
NSWorkspace.shared.open([url],
withAppBundleIdentifier:"com.apple.Safari",
options: [],
additionalEventParamDescriptor: nil,
launchIdentifiers: nil)

关于macos - 通过cocoa应用程序在safari中打开url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21745586/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com