• 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: Bundle identifiers - solution!
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bundle identifiers - solution!


  • Subject: Re: Bundle identifiers - solution!
  • From: Charles Srstka <email@hidden>
  • Date: Sat, 11 May 2002 15:56:26 -0500

On Saturday, May 11, 2002, at 03:49 PM, Simon Jacquier wrote:

Charles Srstka <email@hidden> wrote:

char *wildcard = "****";
NSURL *url;

LSFindApplicationForInfo((OSType)(*wildcard),(CFStringRef)@"com.apple.mail"
,NULL,NULL,(CFURLRef *)(&url));

NSLog([url path]);

Running this gets the path to Mail.app. You need to add
ApplicationServices.framework to your project. You don't need to include
any headers - they're apparently automatically imported by Cocoa.

There is an issue with that code.

If you use it to get the path to a program that is not installed (i.e. a
program that is not part of the default Mac OS X installation, or that as
been deleted by the user) your application will crash. At least the test app
I just built does.

Yeah, that's because I did it as a quick demo, and put absolutely no error checking in. This will not crash:

char *wildcard = "****";
NSURL *url;
OSErr err;

err = LSFindApplicationForInfo((OSType)(*wildcard),(CFStringRef)@"pacifist",NULL,
NULL,(CFURLRef *)(&url));

if(err == noErr)
NSLog([url path]);
else
NSLog(@"App not found");
_______________________________________________
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.

  • Prev by Date: Re: Bundle identifiers - solution!
  • Next by Date: SymLink duplicating troubles
  • Previous by thread: Re: How to implement drag-drop onto application icon
  • Next by thread: SymLink duplicating troubles
  • Index(es):
    • Date
    • Thread