Re: Ownership of nib instances
Re: Ownership of nib instances
- Subject: Re: Ownership of nib instances
- From: Rainer Brockerhoff <email@hidden>
- Date: Thu, 18 Oct 2001 11:22:14 -0200
Date: Wed, 17 Oct 2001 16:33:54 -0700
From: Scott Herz <email@hidden>
Here are <echoing voice> THE RULES:
The File's Owner owns any top level items in the nib. Basically
everything in the document window except First Responder* is a Top Level
Object. It is the responsibility of the File's Owner to release top
level objects. There are some exceptions. For convenience**, windows
will commit suicide for you if you check the Release on Close box. Also,
as mentioned below, if the File's Owner is a window controller, it will
help you out by releasing any top level objects for you.
Many thanks, Scott. I hope the <echoing voice> will return on more topics!
**For whose convenience I don't know...certainly not mine, since I'm
left explaining it all of the time, but I'm happy to do it.
It appears that if you roll your own document class and use it as the
windows owner - pretty much required since you want to point the
owner's window outlet to the window, to have easy access to it - the
window doesn't commit suicide even if you check "Release on Close",
because it'll be retained by the outlet. So the document has to be
released also when you close the window.
I spent some time hunting for this leak, because originally I'd
gotten it backwards - releasing the document when the window was
dealloc'ed, and this never was called.
--
Rainer Brockerhoff <email@hidden>
Belo Horizonte, Brazil
"Originality is the art of concealing your sources."
http://www.brockerhoff.net/ (updated Oct. 2001)