cocoa release nswindowcontroller
I am loading a window with it's controller from a window nib file. The window has a "release when closed" option enabled. How could i开发者_Go百科 release the controller as soon as the window closes?
Thank you
In your windowWillClose:
code don't forget that you'll need to removeObserver:
or your controller will never be released because the NSNotificationCenter has retained it.
In the window controller subscribe to window close notification.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:window];
and in windowWillClose:
method write code to release your window controller.
精彩评论