MOE
MOE

Reputation: 839

run a function when NSWindowController appear

I am currently searching a function like viewDidAppear() in NSWindowController. For my App, I need to display a NSWindowController a few times, and dismiss them with NSApp.hide(nil). But when I show the Window another time, I need to clear a few fields.

Does anyone know how to do that?

Upvotes: 0

Views: 430

Answers (1)

Charles Srstka
Charles Srstka

Reputation: 17040

The easiest thing to do is probably just to use an NSViewController to manage the window's content view (should happen automatically anyway if you're using a storyboard), and then override its viewDidAppear() method. But if you can't do that for some reason, you could always override windowDidLoad() and register for whichever NSWindow notifications are relevant to what you're doing (depending on what that is, didBecomeKeyNotification or didChangeScreenNotification may be helpful).

Upvotes: 1

Related Questions