Ramaprasad Upadhyaya
Ramaprasad Upadhyaya

Reputation: 467

Application Reopen Event - Cocoa/ObjectiveC

I have application1 calling application2 using

[[NSWorkspace sharedWorkspace] launchApplicationAtURL:....

Now, when Application2 opens, I want to do some operation on windows load. This is fine when I open the application first time. I can do my logic in awakeFromNib event.

If the application 2 is minimized (In dock) after open, it opens from the doc when application1 calls application2 again and none of initWithWindow, awakeFromNib, WindowDidLoad is triggering.

Is there any window event which gets triggered when opened from first time or reopen from minimized state?

Upvotes: 0

Views: 249

Answers (1)

Volker
Volker

Reputation: 4658

As an NSApplication delegate you will receive various notifications/calls you can use for that. For example could you use

- (void)applicationDidBecomeActive:(NSNotification *)aNotification
- (void)applicationDidResignActive:(NSNotification *)aNotification

You may only have to check first start vs. becoming active using a variable in your app delegate. Also, DidBecomeActiveshould be called also on startup.

Upvotes: 1

Related Questions