Search code examples
objective-ccocoaappkit

What is responsible for releasing NSWindowController objects?


Lets say I display a window like so:

[[TBAddTaskWindowController new] showWindow:self];

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.


Solution

  • 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.