If it is absolutely necessary to use NSTask for launching the app, you can also use the "open" command which honours the one instance per-app rule properly. However, I agree that NSWorkspace is the best thing to use in most cases.

Mike.

On 16 Apr 2008, at 15:43, Jens Alfke wrote:


On 16 Apr '08, at 5:16 AM, Praveen Kumar wrote:

Instead of AppleScript, I tend to use NSTask to launch the application, but it won't use the active application instead it opens another one and do the stuff.

Launching GUI apps via low-level Unix system calls (as NSTask does) can be problematic. CoreServices, which keeps track of application processes, either isn't aware of those, or is but treats them differently; I'm not sure which. I do know that the "only one copy of an app can be running at once" rule only applies to apps launched by LaunchServices; so if you start one yourself via exec or NSTask, and then something goes through the normal launch mechanism (in this case AppleScript), a second copy will be launched.

It would be better if you used NSWorkspace to launch your app. Or for more control, you can call LaunchServices directly.

—Jens_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/cocoadev%40mikeabdullah.net

This email sent to [EMAIL PROTECTED]

_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to