0

On iOS, there are viewDidAppear / viewDidDisappear methods. They are also being added to Yosemite (see https://developer.apple.com/library/prerelease/mac/releasenotes/AppKit/RN-AppKit/#10_10ViewController).

Question: how can I detect when my view is appearing / disappearing pre-OS X 10.10?

Michael Teper
  • 4,591
  • 2
  • 32
  • 49
  • Just an idea: perhaps there's some room for overriding `addSubview:` etc. in a subclass...? I'm guessing the `superview` property is readonly, so intercepting `setSuperview:` is not possible... – Nicolas Miari Aug 19 '14 at 01:40

2 Answers2

-1

You can use loadView

- (void)loadView {
    [super loadView];

}

I don't know your goal but if you really needed it. There was viewDidUnload and viewWillUnload but Apple deprecated them and warned people that they are being misused.

The cost of releasing objects when the view unload is not expensive so they just got rid of it.

meda
  • 45,103
  • 14
  • 92
  • 122
-1

The only way I can see pre-Yosemite systems using something similar to viewDidDisappear is to subclass NSView and overriding viewDidHide to call a delegate class.

Or you could do some method swizzling on the NSView class on pre-Yosemite systems.

MaddTheSane
  • 2,981
  • 24
  • 27