Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
- Subject: Re: Outlets / IBOutlet declarations (was Re: Interface Builder & Wiring Objects)
- From: Brian Stern <email@hidden>
- Date: Mon, 17 Nov 2008 22:46:52 -0500
On Nov 17, 2008, at 10:17 PM, Luke the Hiesterman wrote:
On Nov 17, 2008, at 7:12 PM, Brian Stern wrote:
OK, this issue has come up for me very recently. It appears that
on iPhoneOS IBOutlets are retained, regardless of the presence of
properties. Even worse, in the presence of an assign property the
outlet is still retained. Whatever code is retaining the outlets
never releases them. So it seems that client code must release all
outlets.
Seems to me that the outlets must have a retain count of at least
one when they're unarchived, as though they were alloc'd. It makes
sense that the programmer should have to manually release objects in
dealloc. How else would it happen?
IBOutlets are not necessarily top level objects. Most are simply
views that happen to be in the view hierarchy. There will typically
be one top level object in an iPhone nib. This will be the view that
belongs to UIViewController. It is the UIViewController base class
that loads the nib. As long as it retains that top level view then
all the subviews will also be retained. They should be released when
the UIViewController releases its view outlet.
Furthermore, NSBundle loadNibNamed:owner:options: on iPhone OS returns
an array of the top level objects. It would be trivial for the
UIViewController base class object that is loading the nib to retain
that array and of course release it in its dealloc.
If user code doesn't retain the outlets I don't understand why user
code should be releasing those objects.
--
Brian Stern
email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden