I have a subclass of NSWindowController like this:
@interface MyController : NSWindowController <NSWindowDelegate>
...
- (void)windowWillClose:(NSNotification *)notification;
@end
It is the delegate of his window. Everything work OK.
But, to avoid leaking memory, should I do this in the implementation ?
@implementation MyController
...
- (void)windowWillClose:(NSNotification *)notification {
...
[self release];
}
@end
If I don't do this, when I close the window with the little red close button, windowWillClose: is called, and in Instrument I see that the NSWindow is released but not the MyController...
Is this "the way" of doing it ? Or am I taking risk ?
Note: with Command-W the window and the controller are properly released since I'm catching this action in the AppDelegate, the one that has instantiated all this window & controller and therefore know how/when to release them. But the little red close button performClose: on it's own and the best I have achieved is to catch windowWillClose: as a window delegate...