Re: Better way to launch applications in Cocoa
Re: Better way to launch applications in Cocoa
- Subject: Re: Better way to launch applications in Cocoa
- From: Mark Douma <email@hidden>
- Date: Sat, 16 Jul 2005 17:27:42 -0400
On Jun 25, 2005, at 9:09 PM, Ali Ozer wrote:
As of Panther NSWorkspace has a launchAppWithBundleIdentifier:...
method which lets you specify launch options, so:
[[NSWorkspace sharedWorkspace]
launchAppWithBundleIdentifier:@"com.apple.TextEdit"
options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:nil
launchIdentifier:NULL];
If you don't have a bundleIdentifier for your app, you can use the
openURLs:... variant, passing your app's path as the URL:
[[NSWorkspace sharedWorkspace] openURLs:[NSArray arrayWithObject:
[NSURL fileURLWithPath:@"/Applications/TextEdit.app"]]
withAppBundleIdentifier:@""
options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:nil
launchIdentifiers:NULL];
Ali
For some reason, I cannot get this to work properly when the target
application happens to be the Finder. (I send a Quit Apple event to
the Finder, then wait to receive a notification that it's quit, and
then I launch it using that NSWorkspace method). Even with the
NSWorkspaceLaunchWithoutActivation option, the Finder will bring
itself to the front upon launch. Any way to work around this?
I suppose I could send myself an 'rapp' Apple event to reactivate my
app?
Thanks in advance....
------------------------------------------------------------------------
---
Mark Douma
Grand Rapids, MI, USA
email@hidden
http://homepage.mac.com/mdouma46/
------------------------------------------------------------------------
---
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden