什么负责释放 NSWindowController 对象? [英] What is responsible for releasing NSWindowController objects?

查看:18
本文介绍了什么负责释放 NSWindowController 对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我像这样显示一个窗口:

Lets say I display a window like so:

[[TBAddTaskWindowController new] showWindow:self];

[[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 消息来实例化窗口控制器的相同代码,就像它已经完成一样通过 allocinit 消息.

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 对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆