开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜