3

我正在从窗口 nib 文件中加载带有控制器的窗口。该窗口启用了“关闭时释放”选项。窗口关闭后如何释放控制器?

谢谢

4

2 回答 2

2

在您的windowWillClose:代码中不要忘记您需要这样做,removeObserver:否则您的控制器将永远不会被释放,因为 NSNotificationCenter 已保留它。

于 2011-08-18T09:49:10.103 回答
1

在窗口控制器中订阅窗口关闭通知。

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowWillClose:) name:NSWindowWillCloseNotification object:window];

并在windowWillClose:方法中编写代码以释放您的窗口控制器。

于 2011-07-04T11:03:52.950 回答