开发者

cocoa release nswindowcontroller

开发者 https://www.devze.com 2023-03-16 07:16 出处:网络
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 close

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

精彩评论

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