Reputation: 33110
- (void)applicationWillBecomeActive:(NSNotification *)notification
{
NSRunAlertPanel(@"Wee I am called", @"Hello", @"OK", @"Alternate Button", @"OtherButton");
[showdesktop showDeskHideMe];
}
The problem with code above is it's only launched when the app is first launched.
If after that I open up other apps, and then click the apps again from the dock, the code will not be launched.
How do I do that?
How to "deactivate" an application anyway?
Note: This is about MacOs, not IOS!!!
Upvotes: 0
Views: 93
Reputation: 1006
Have a look at the "Notifications" section here: https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/nsapplication_Class/Reference/Reference.htm ( Sorry, can't find a direct link )
There are a bunch of notifications which you can catch ranging a wide array of different events. For example, NSApplicationDidUnhideNotification
seems interesting in your case.
You can use the NSNotificationCenter
to pick up on these notifications.
For more information about the NSNotificationCenter check: https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Notifications/Introduction/introNotifications.html#//apple_ref/doc/uid/10000043i
Upvotes: 1
Reputation: 1317
Try the following methods:
- (void)applicationWillResignActive:(UIApplication *)application
{}
- (void)applicationDidEnterBackground:(UIApplication *)application
{}
- (void)applicationWillEnterForeground:(UIApplication *)application
{}
Upvotes: 1