I have a subclass of NSWindowController, for example:
@interface MyController : NSWindowController <NSWindowDelegate> ... - (void)windowWillClose:(NSNotification *)notification; @end
This is the delegate of his window. Everything is working fine.
But, to avoid a memory leak, should I do this in an implementation?
@implementation MyController ... - (void)windowWillClose:(NSNotification *)notification { ... [self release]; } @end
If I do not, when I close the window with the red close button, windowWillClose is called: and in Instrument I see that NSWindow is released, but not MyController ...
Is this the "way" of this? Or am I taking a chance?
Note : with Command-W, the window and the controller are correctly released, since I catch this action in AppDelegate, the one that created all this window and the controller and therefore knows how / when to release them. But the little red close button executesClose: on it, my own and the best I have achieved is to catch windowWillClose: as a window delegate ...
source share