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: Chris Hanson <email@hidden>
- Date: Thu, 25 Sep 2003 12:03:16 -0500
On Wednesday, September 24, 2003, at 06:35 PM, M. Uli Kusterer wrote:
I'm using [NSBundle loadNibNamed: @"MyNibFile" owner: self]; in one
of my classes' -init method. It works like a charm, but I just
realized that I don't know how I'm supposed to dispose of the loaded
objects.
If you use -[NSBundle loadNibNamed:owner:] the owner is responsible for
releasing all top-level objects. To do so you'll need to be sure there
are outlets to all of them in the owner, either directly or indirectly.
If you load a nib indirectly through the NSWindowController mechanism
(for instance, by instantiating a subclass of NSWindowController that
overrides -windowNibName and sending it -showWindow:) then the
NSWindowController is the nib's owner, and is responsible for releasing
all top-level objects. (It will, too, using an internal API.)
-- Chris
--
Chris Hanson, bDistributed.com, Inc. | Email: email@hidden
Custom Mac OS X Development | Phone: +1-847-372-3955
http://bdistributed.com/ | Fax: +1-847-589-3738
http://bdistributed.com/Articles/ | Personal Email: email@hidden
_______________________________________________
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.