Re: loadNibNamed:owner: Who disposes of the loaded objects?
Re: loadNibNamed:owner: Who disposes of the loaded objects?
- Subject: Re: loadNibNamed:owner: Who disposes of the loaded objects?
- From: Vince DeMarco <email@hidden>
- Date: Thu, 25 Sep 2003 10:20:08 -0700
On Sep 25, 2003, at 5:10 AM, M. Uli Kusterer wrote:
At 16:52 Uhr -0700 24.09.2003, Matthew Formica wrote:
<http://developer.apple.com/documentation/Cocoa/Conceptual/
LoadingResources
/Concepts/NibFileLoaded.html>
"Releasing Nib File Objects
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.
I don't think there's a link to this page anywhere on the page that
documents loadNibNamed:owner:, is there? I option-clicked
loadNibNamed: and then looked around starting there, but didn't find
anything. It'd be helpful if there was a link at the top with all the
other "Techniques and Concepts" entries on that page pointing to this.
Do I have to file a bug on this, or could you forward that info to
the documentation team?
Note that NSWindowController automatically releases its nib file's
objects
for you. Also, NSWindow has a isReleasedOnClose attribute, which
automatically releases the window for you when it's closed."
If I want to provide the same behavior as NSWindowController in my
app, how do I determine what objects are in my NIB file? Currently,
all objects are in an NSView resp. an NSPanel, but later there may be
other objects in there, and I'd like to avoid leaking anything.
From the IB FAQ (which is on all of your machines In IB got to
Help->FAQ)
Should I release top level objects at runtime?
Usually, yes. The File's Owner is responsible for releasing any
resources created by the nib. These include any top level objects such
as formatters, custom views, extra window or extra menus. However,
there are a few exceptions to this rule. Windows with the "Release on
Close" flag set do not need to be released. They will release
themselves when they close. Windows controlled by a window controller
will also be release automatically.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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.