Does NSViewController increase notification of its addition or removal?

For iOS, I used the UIViewController viewWillAppear and viewWillDisappear to connect and detach listeners from the controller model. Thus, the controller does not take any action if it is not displayed, and can ensure that everything is synchronized when the view is displayed.

I would like to do the same for the Mac, but I don’t see how the NSViewController receives a notification that its view is being added or removed from the screen. Should I just subclass NSViewController, add notification methods, and is there anyone adding / removing views that calls these methods?

+5
source share
2 answers

This is an old question, but the answer is "No, it will not be notified." You need subclasses and do it yourself. I also connected my subclass to the responder chain.

0
source

Like Yosemite, the answer is now "Yes."

+1
source

All Articles