views:

59

answers:

3

Hi,

I cannot seem to find it in the documentation but I'm looking for a way to run a method whenever a window is displayed on screen after launch of my app or after it has been closed and then reopened again.

+2  A: 

NSWindowController:
– windowDidLoad
– windowWillLoad

Then I'll only know when the window got loaded (in my case only once).
Jim Cooper
A: 

Is it iPhone or Mac?

Your window contains views, and they have their viewDidAppear methods. You should use them, I think.

Alistra
iPhone doesn't have NSWindow
Kevin Ballard
I'll try that..
Jim Cooper
A: 

You could try using NSWindowDidBecomeKeyNotification or NSWindowDidBecomeMainNotification. These are called when the window becomes key/main rather than when it's put on-screen, but most windows are made key/main when they go on-screen. You could also experiment with the other NSWindow notifications (see the bottom of the documentation page for NSWindow), it's possible that some of them may be called when the window goes on-screen.

Kevin Ballard
That was my first idea too. But after all, it's not what I'm after.
Jim Cooper