Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6893309
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:38:34+00:00 2026-05-27T06:38:34+00:00

For example, get the notification that another Application is becoming Active on the screen,

  • 0

For example, get the notification that another Application is becoming Active on the screen, or resign active state.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:38:35+00:00Added an answer on May 27, 2026 at 6:38 am

    Sure. In your app delegate class, you can use NSWorkspace to get notified when an app becomes active (NSWorkspaceDidActivateApplicationNotification) or resigns active (NSWorkspaceDidDeactivateApplicationNotification). See the documentation on NSWorkspace for more info.

    In your controller class, you’d do something like this:

    - (id)init {
       if ((self = [super init])) {
           [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self
                                 selector:@selector(appDidActivate:)
                                name:NSWorkspaceDidActivateApplicationNotification
                                  object:nil];
       }
       return self;
    }
    
    - (void)dealloc {
        [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
        [super dealloc];
    }
    
    - (void)appDidActivate:(NSNotification *)notification {
       NSDictionary *userInfo = [notification userInfo];
       NSLog(@"userInfo == %@", userInfo);
    
    }
    

    The key points are basically that you need to register to receive the notifications like shown in -init. You’d repeat the code to add another observer for each additional notification name that you want (e.g NSWorkspaceDidDeactivateApplicationNotification).

    Another important thing to remember is to remove yourself as an observer in -dealloc (or elsewhere), so that NSWorkspace doesn’t try to notify your controller object after it’s been released+dealloc’d (and would no longer be valid).

    In the specified -appDidActivate: method, do whatever you need to with the info about the app in question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Question Summary: how can I get the path to the currently active application under
For example, when memory gets low, the System sends a UIApplicationDidReceiveMemoryWarningNotification notification. That's all
I'm working on a browser-based application that needs to be able to get users'
Here is an example to get different parts of a filename bash-3.2$ pathandfile=/tmp/ff.txt bash-3.2$
How to converted string with space in double quoted string. For Example: I get
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I cannot get the example Python programs to run. When executing the Python command
how can i get for example the integer codeInt=082 from String code='A082' i have
I was able to find example code to get the current timestamp in Linux
I've been unsuccessful in trying to find an example how to get a sqlite

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.