0

I'm trying to figure out how to tell a browser (in this example, Google Chrome) how to open in incognito mode. I'm using the NSWorkspace openurls method, but I can't find any way of send the application extra parameters.

func openUrlWithBrowser(url: String, bundleIdentifier: String) {
    var eventDescriptor: NSAppleEventDescriptor? = NSAppleEventDescriptor()
    var errorInfo : NSDictionary? = nil
    var appleEventManager:NSAppleEventManager = NSAppleEventManager.sharedAppleEventManager()
    var urls = [NSURL(string: url)!]
    NSWorkspace.sharedWorkspace().openURLs(urls, withAppBundleIdentifier: bundleIdentifier, options: NSWorkspaceLaunchOptions.Default, additionalEventParamDescriptor: nil, launchIdentifiers: nil)
}
John Sterling
  • 1,091
  • 7
  • 13
  • Not sure if this helps you, but I've used this command-line script to launch Chrome in incognito mode: `open -a "/Applications/Google Chrome.app" --args --incognito "https://google.com"`. Perhaps you could invoke something like that instead of using `openURLs`? – Matt Brictson Jul 01 '15 at 23:23
  • I've considered this solution as well, but I feel there should be some better way. Pretty new to coding in Swift/OSX. – John Sterling Jul 02 '15 at 07:04
  • Does this help? http://stackoverflow.com/questions/5048677/launching-an-mac-app-with-objective-c-cocoa – empedocle Jul 02 '15 at 08:54

0 Answers0