Re: checking to see if the application exists in a certain location
Re: checking to see if the application exists in a certain location
- Subject: Re: checking to see if the application exists in a certain location
- From: Nick Zitzmann <email@hidden>
- Date: Mon, 5 May 2003 14:53:59 -0700
On Monday, May 5, 2003, at 10:38 AM, Charles Bennion wrote:
I have been working on creating a Status Bar application that will
launch a few applications from a NSMenu. I have it working just fine
but I am interested in getting it to verify that the application exists
before it tries to launch it and if does not exists to display a dialog
that it is not installed. Right now this is all of the code that it
uses when selecting the NSMenu item:
-(IBAction)launchDTLogin:(id)sender{
// It launches much faster with the fullPathForApplication set
[[NSWorkspace sharedWorkspace]
fullPathForApplication:@"/Applications/DTApps/LoginApp.app"];
[[NSWorkspace sharedWorkspace] launchApplication:@"LoginApp.app"];
}
Well, you could use [[NSFileManager defaultManager]
fileExistsAtPath:pathToApplication] where pathToApplication is the path
as an NSString...
Some words of advice: Don't ever depend on files to be installed in
certain paths outside of the application bundle. A lot of your users
will probably react negatively to this, since it's been a long-running
tradition on the Macintosh that non-system software components can be
installed anywhere... You can use Launch Services to locate any
specific file on the disk using some alternate metadata criteria.
Nick Zitzmann
AIM/iChat: dragonsdontsleep
Check out my software page:
http://dreamless.home.attbi.com/
"Great spirits have always encountered violent opposition from mediocre
minds." - Albert Einstein
_______________________________________________
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.