Re: of nibs and top level objects
Re: of nibs and top level objects
- Subject: Re: of nibs and top level objects
- From: j o a r <email@hidden>
- Date: Mon, 10 Apr 2006 09:31:52 +0200
On 10 apr 2006, at 09.06, Paul Forgey wrote:
When the node is no longer needed, it is told to "unload" and
hopefully releases all the top level nib items.
Hopefully? As in that's what it should do, but it seems that it doesn't?
I'm having a lot of trouble doing this. I've managed to account
for about 14 retain counts, which is about 14 short of the total
needed to bring the total count back to 0.
Among your retain events, are there any suspects? Anything related to
bindings?
If the node loads a nib file, it never goes away.
The node?
In the list archives, I stumbled over this bit of code following
and it seems to be giving back a reasonable list of items. By
retaining the array I hold onto the items, then release the array
when I'm done.
What do you hope to accomplish by doing this, compared with regular
nib loading?
When you're tracking retain-release events, do you see that it makes
any difference?
What more do I need to do, and is there clearer documentation than
what's in the Application Kit section about NSBundle additions
which just says I need to "release all the top level items" with no
further information about how to actually _do_ this?
In the general case you would just have to do this:
- (void) dealloc
{
[topLevelNibObject release];
// ...repeat for other top level objects
[super dealloc];
}
If an object is loading multiple nib files during it's lifetime, it
would of course have to do more work in order to keep track of it's
top level items - but the theory is the same. It's just basic Cocoa
memory management. When you load a nib file you assume memory
management ownership of the top level items, meaning that you have to
release them at the appropriate time. There's nothing more to it.
One thing that may be complicating matters is there are bindings in
this nib referring to objects in the document window controller's
nib. That object owning the document nib is not over-retained. It
still dealloc's when the document closes.
No, they're not referring to object in some other nib file - because
cross-nib connections are not supported (This is a detail of course,
but for this discussion I think it would be better if you make a
clear distinction between archived objects in a nib file and "live"
objects at runtime.). They might of course still reference the actual
window controller, via key paths or otherwise.
One thing that may be complicating matters is there are bindings in
this nib referring to objects in the document window controller's
nib. That object owning the document nib is not over-retained. It
still dealloc's when the document closes.
Do you have any evidence to support the idea that bindings are
related to your problem? If you remove the bindings (work on a copy
of your project / nib), does it work as expected?
How about setting up and tearing down your bindings manually in code?
At least it might be good for troubleshooting purposes.
j o a r
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden