In a class I do something like the following:
- (void)windowDidLoad
{
[super windowDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillClose:)
name:NSWindowWillCloseNotification
object:self.window];
}
- (void)windowWillClose:(NSNotification *)notification {
NSLog(@"closing");
}
Then I subclass this class. There’s only one problem. When I subclass this class, the notification is never sent. Is there a reason for this?
Does your subclass override
windowDidLoadand/orwindowWillClose:? If so, do your subclass’s implementation(s) callsuper?