Re: How to completely release every object allocated when opening a NIB file ?
Re: How to completely release every object allocated when opening a NIB file ?
- Subject: Re: How to completely release every object allocated when opening a NIB file ?
- From: Charles Srstka <email@hidden>
- Date: Tue, 13 Jan 2004 22:12:47 -0600
The constant defined in NSNib is NSNibTopLevelObjects, not
NSTopLevelObjects. What's more, NSNibTopLevelObjects of course appears
in the binary for 10.3, but doing a grep on the 10.1 Frameworks folder
yields nothing. NSTopLevelObjects, on the other hand, does appear in
the AppKit binary in both 10.1 and 10.3, but as it seems to be
undocumented, who knows if it will go away in some future release.
Which brings me to the point, isn't this badly broken? The point of
Cocoa's reference counting was that you were supposed to only have to
release something if you specifically called init or retain on it. As
it is, the rule has to be extended to: "You only need to release
something if you called init or retain on it. Except for top-level
objects in nib files, which you own and have to release, even though
you didn't call retain or init, even though your code might not even
*know* about those objects, and even though the nib file could be
edited after you write the code and your code could have to deal with
objects that didn't *exist* at the time the code was written. Oh, and
forget this rule for NSDocument's nib file, which *will* release the
objects, causing you to crash if you try to release them. So don't
release those! But do release everything in everything other nib file.
Wait, unless you use a NSWindowController, because *it* will release
the nib file objects... but oh, Cocoa's memory management is easy!"
Try explaining *that* to a newbie and expecting him/her to keep it
straight.
Charles
On Jan 13, 2004, at 4:58 PM, j o a r wrote:
On 2004-01-13, at 23.07, Charles Srstka wrote:
However, I can't find mention of @"NSTopLevelObjects" in any of the
headers or documentation. Is this an undocumented technique, and thus
is it possible that it could stop working in future versions of Mac OS
X?
It's at least documented in NSNib, available since 10.3...
How far back does this trick work? Does it work in 10.1?
...but the keys were present earlier, problably pre-Mac OS X.
j o a r
[demime 0.98b removed an attachment of type
application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.