Relaunch App (Quit, Relaunch If Quit)?
Relaunch App (Quit, Relaunch If Quit)?
- Subject: Relaunch App (Quit, Relaunch If Quit)?
- From: "Chunk 1978" <email@hidden>
- Date: Wed, 14 Jan 2009 10:25:13 -0500
my goal is to quit an app, check to see if it has quit, and then
relaunch the app if it has quit successfully. i'm sending
quit/relaunch commands with applescripts (tell application "Finder" |
quit | end tell, tell application "Finder | launch | end tell), and
i'm attempting to make this code work without using any type of delay
mechanism but i'm lost.
the following code works very well on quitting and relaunching the
Finder, except if the Finder is busy (copying a file, or something),
the program will continuously try to quit the finder while the finder
prompts that it's busy - it's a continuous loop... a bad scene...
essentially i need to somehow figure out how to have this loop quit
the finder, but stop the loop if it's busy...
-=-=-=-
- (IBAction)restartFinder:(id)sender
{
//Quit Finder
NSDictionary* errorDict = nil;
NSAppleEventDescriptor *returnDescriptor = nil;
returnDescriptor = [quitFinderScriptObject executeAndReturnError:&errorDict];
//Check To See If Finder Has Quit
NSWorkspace *ws = [NSWorkspace sharedWorkspace];
NSArray *runningAppDictionaries = [ws launchedApplications];
NSDictionary *aDictionary;
for (aDictionary in runningAppDictionaries)
{
//If Finder Hasn't Quit Then Return
if ([[aDictionary valueForKey:@"NSApplicationBundleIdentifier"]
isEqualToString:@"com.apple.finder"])
{
[self restartFinder:nil];
return;
break;
}
}
//If Finder Has Quit Then Continue To Relaunch Finder
NSDictionary* errorDict = nil;
NSAppleEventDescriptor *returnDescriptor = nil;
returnDescriptor = [startFinderScriptObject executeAndReturnError:&errorDict];
}
-=-=-=-
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden