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: Jonathan Hess <email@hidden>
- Date: Mon, 17 Nov 2008 21:35:05 -0800
Perhaps the new @property() syntax makes it easy to forget about
object lifetimes because it does the set/get/change automagically.
These days when I add any property I go right to the dealloc method
(and init if I have one) and ensure I've managed that property
before I forget.
Yes, but this is exactly the point. If I have no property for an
Outlet it's still retained.
Hey Brian -
Outlets for iPhone OS are established by calling setValue:forKeyPath:.
The behavior of setValue:forKeyPath: is that if a setter exists, it is
called. If a setter does not exist, the instance variable is looked up
and set directly, and if it is an object, it is retained. This means
that for IBOutlets, with no setters, they're retained in iPhone OS.
This is different from Mac OS X. If you're writing code on both
platforms, or are planning to, you should always use properties on
both platforms since it makes the decision to retain outlets explicit
and obvious.
Jon Hess
_______________________________________________
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