问题描述
假设我像这样显示一个窗口:
Lets say I display a window like so:
[[TBAddTaskWindowController new] showWindow:self];
TBAddTaskWindowController 对象在哪里被释放?是在windowWillClose 中调用[self release] 的通用解决方案吗?
Where is the TBAddTaskWindowController object meant to be released? Is the generic solution to call [self release] in windowWillClose?
让任何其他对象拥有"窗口感觉是不对的,因为它意味着在用户关闭它之前一直存在.
It doesn't feel right to have any other object "own" the window, because it's meant to exist until the user closes it.
推荐答案
通过向类发送 new
消息来实例化窗口控制器的相同代码,就像它已经完成一样通过 alloc
和 init
消息.
The same code that instantiated the window controller by sending the new
message to the class, just the same as if it had done it by alloc
and init
messages.
这篇关于什么负责释放 NSWindowController 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!