Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does NSViewController get notified when its view is added or removed?

For iOS, I was using UIViewController's viewWillAppear and viewWillDisappear to hook up and unhook listeners on the controller's model. This way the controller doesn't do any work if it's view is not being shown, and can make sure everything is synced up when the view is shown.

I'd like to do the same for Mac, but don't see any way that an NSViewController gets notified about its view being added or removed from the display. Should I just subclass NSViewController, add the notification methods, and have whoever adds/removes the views call those methods?

like image 860
initlaunch Avatar asked Nov 14 '22 23:11

initlaunch


1 Answers

As of Yosemite, the answer is now "Yes."

like image 175
MaddTheSane Avatar answered Dec 21 '22 07:12

MaddTheSane