• 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: How to deactivate an app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to deactivate an app


  • Subject: Re: How to deactivate an app
  • From: Ken Thomases <email@hidden>
  • Date: Wed, 01 Feb 2012 01:29:10 -0600

On Feb 1, 2012, at 1:20 AM, Gerriet M. Denkmann wrote:

> I tried:
>
> - (void)applicationWillBecomeActive:(NSNotification *)aNotification
> {
> 	(void)aNotification;
>
> 	NSRunningApplication *currentApplication = [ NSRunningApplication currentApplication ];
> 	NSString *bundleIdentifier = currentApplication.bundleIdentifier;
> 	NSLog(@"%s current: %@",__FUNCTION__, bundleIdentifier);
>
> 	NSWorkspace *sharedWorkspace = [ NSWorkspace sharedWorkspace ];
> 	NSArray *runningApplications = [ sharedWorkspace runningApplications ];
> 	for( NSRunningApplication *ru in runningApplications )
> 	{
> 		if ( ru.isActive )
> 		{
> 			NSString *bundleIdentifier = ru.bundleIdentifier;
> 			NSLog(@"%s active: %@",__FUNCTION__, bundleIdentifier);
> 		};
> 	};
> }
>
> But both the currentApplication and the active one is our app (NOT the previously active one).
>
> Although the name of the notification is applicationWillBecomeActive it acts more like
> applicationIsAlreadySomehowActiveAndWIllBecomeFullyActiveRealSoonNow.

Well, remember that this is Cocoa responding to an event delivered from the system.  Events are delivered asynchronously.  The system can't afford to wait for an app to respond to an event before moving on.

There is bound to be an interval of time between when the system changed which app is active and when Cocoa actually acts on the event it received because of that change.

Regards,
Ken


_______________________________________________

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


References: 
 >Re: How to deactivate an app (From: Lee Ann Rucker <email@hidden>)
 >Re: How to deactivate an app (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: How to deactivate an app
  • Previous by thread: Re: How to deactivate an app
  • Next by thread: Re: How to deactivate an app
  • Index(es):
    • Date
    • Thread