Re: Toplevel Objects in NIB files
Re: Toplevel Objects in NIB files
- Subject: Re: Toplevel Objects in NIB files
- From: Vince DeMarco <email@hidden>
- Date: Mon, 16 Sep 2002 12:55:32 -0700
On Sunday, September 15, 2002, at 09:49 PM, James DiPalma wrote:
From: Dustin Voss <email@hidden>
Is it true what the docs say about having to release top-level
objects (in file:///Developer/Documentation/Cocoa/TasksAndConcepts/
ProgrammingTopics/LoadingResources/index.html) when loading a NIB
manually?
LoadingResources/index.html on 10.1:
"When you load a nib file, all its top level objects have a reference
count of one. When the objects are no longer needed, another object
needs to release them. That other object is usually the file's owner."
Short answer: yes; long answer: many top-level objects do not have a
referrence count of one after being loaded from a nib file, but they
were all owned by an object that is irresponsible and therefore need
to be released/autoreleased by another object.
What do they mean by top-level objects?
Vince DeMarco answered this question:
NSTopLevelObjects is basically what you see in the icon view in the
IB Document, What the document contains (its hierarchy) can be seen
by switching the document window in IB to outline mode
They obviously can't mean File's Owner and First Responder,
Since FirstResponder is actually nil, you don't need to worry about
its retain count. File's owner? No.
What about a naked NSView object that my code puts somewhere else in
the view hierarchy?
Yes.
What about the Font Manager object?
Good question. I could guess, but I've never actually checked and I
don't know if it matters.
If I don't connect it to an outlet, do I still need to free it?
Yes.
If so, how?
You'll probably get lots of answer on this one. Its too late and I
don't have anything useful to say.
Don't release the Font Manager, its a shared instance in the AppKit.
There is only one.
vince
_______________________________________________
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.