Re: Bundle identifiers - solution!
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.