Re: Launching an App without NSWorkspace?
Re: Launching an App without NSWorkspace?
- Subject: Re: Launching an App without NSWorkspace?
- From: Kurt Revis <email@hidden>
- Date: Wed, 4 Sep 2002 20:39:23 -0700
On Wednesday, September 4, 2002, at 08:13 PM, Ryan Stevens wrote:
Yeah, you wouldn't want to do it the easy way...
system("open someApp");
That would be nice, if it worked. You need to specify the full path to
the application, though.
And in that case, you might as well just do this:
NSString *applicationPath; // I assume you have this
NSURL *applicationURL;
applicationURL = [NSURL fileURLWithPath:applicationPath];
LSOpenCFURLRef((CFURLRef)applicationURL, NULL);
which is a whole lot more direct and reliable. Even if you add error
checking, this doesn't come out to very much code.
Very roughly: Calling system() will run a shell, which interprets the
text you give it, and then finds the 'open' command (assuming your
path isn't screwed up), and forks and exec's it. Open then needs to do
a bunch of work to initialize the Obj-C runtime and Cocoa, and then
calls into NSWorkspace, which then ... guess what ... probably does
just about the same Launch Services calls as the ones above. Why not
just do it directly?
Also, I think it's worth knowing about all the functionality available
in the system. There are some features in LaunchServices that you can't
get elsewhere. The original poster didn't give enough detail to
determine whether the Launch Services stuff would be useful for him, or
not.
--
Kurt Revis
email@hidden
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.