• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Launching an App without NSWorkspace?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Follow-Ups:
    • Re: Launching an App without NSWorkspace?
      • From: Douglas Davidson <email@hidden>
    • Re: Launching an App without NSWorkspace?
      • From: Isaac Sherman <email@hidden>
    • Re: Launching an App without NSWorkspace?
      • From: Kurt Revis <email@hidden>
References: 
 >Re: Launching an App without NSWorkspace? (From: Ryan Stevens <email@hidden>)

  • Prev by Date: Re: Launching an App without NSWorkspace?
  • Next by Date: Re: cString deprecated!
  • Previous by thread: Re: Launching an App without NSWorkspace?
  • Next by thread: Re: Launching an App without NSWorkspace?
  • Index(es):
    • Date
    • Thread