I want to open a URL in Cocoa through my app in Safari only. I am using:
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString: @"my url"]];
But the problem is that if my default browser is not Safari, then the URL gets open in some other browser. But I want my URL to open in Safari only. Please tell the solution.
Thanks :)
Helpful answers. It's http://www.apple.com/startpage/ . then go into Safari > Preferences and click General > Set to current page.
Opening Content in Safari View ControllerRun the app and tap the bottom button, "Open with safari view controller", to see the content now being displayed inside a SFSafariViewController instance. We've now let the user stay inside of our app and they have all the advantages of Safari.
how to open url in safari from my app? When user click on the button open safari with given url.
let url = URL(string:"https://twitter.com/intent/tweet")!
NSWorkspace.shared.open([url],
withAppBundleIdentifier:"com.apple.Safari",
options: [],
additionalEventParamDescriptor: nil,
launchIdentifiers: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With