• 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
Relaunch App (Quit, Relaunch If Quit)?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Relaunch App (Quit, Relaunch If Quit)?
      • From: Jean-Daniel Dupas <email@hidden>
  • Prev by Date: Re: How font size managed without affecting the font? Please help
  • Next by Date: Re: Capture video from core animation (QC)
  • Previous by thread: Re: Service request fails if provider has not yet launched
  • Next by thread: Re: Relaunch App (Quit, Relaunch If Quit)?
  • Index(es):
    • Date
    • Thread