NSViewのサブクラスでサイズ変更を検出するには、特定のメソッドをオーバーライドするのではなく、NSNotificationCenterを使う。もちろん、この方法ではサブクラスでなくても通知を受けることが出来る。
-[NSView initWithFrame:]などでNSNotificationCenterに登録する。
[[NSNotificationCenter defaultCenter] addObserverForName:NSViewFrameDidChangeNotification
object:self
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note){ /* 処理 */ }];
Blocksを使わなければこう。
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(hoge:)
name:NSViewFrameDidChangeNotification
object:self];
通知を受け取るメソッド(例ではhoge:)は第一引数にNSNotification*をとる必要がある。
NSOpenGLViewには-updateや-reshapeがあるので、NSViewにもそういうのがあるかと思っていた。
まぁ、もしそうならわざわざNSOpenGLViewで宣言したりしないよね。