可可发布nswindowcontroller
我正在从窗口 nib 文件加载一个带有控制器的窗口。该窗口启用了“关闭时释放”选项。如何在窗口关闭后立即释放控制器?
谢谢
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 release the controller as soon as the window closes?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在您的
windowWillClose:
代码中,不要忘记您需要removeObserver:
,否则您的控制器将永远不会被释放,因为 NSNotificationCenter 已保留它。In your
windowWillClose:
code don't forget that you'll need toremoveObserver:
or your controller will never be released because the NSNotificationCenter has retained it.在窗口控制器中订阅窗口关闭通知。
并在
windowWillClose:
方法中编写代码来释放窗口控制器。In the window controller subscribe to window close notification.
and in
windowWillClose:
method write code to release your window controller.