Re: resetting ivars safely
Re: resetting ivars safely
- Subject: Re: resetting ivars safely
- From: "Shawn Erickson" <email@hidden>
- Date: Wed, 12 Sep 2007 15:26:41 -0700
On 9/12/07, Chris Hanson <email@hidden> wrote:
> On Sep 12, 2007, at 1:59 PM, Daniel Child wrote:
>
> > Here is the relevant code. Thanks much....
>
> Since your class manages a couple of mutable collections, I'd just set
> those up in -init, release them in -dealloc, and otherwise manipulate
> the collections themselves in the accessor methods.
>
> I also wouldn't provide an accessor to the underlying mutable array,
> only an immutable array. Instead, I would write the appropriate KVC
> accessor methods (see <Foundation/NSKeyValueCoding.h> for details) and
> either call those directly or use -mutableArrayValueForKey: on the
> property to manipulate it from my own code. Doing so will ensure the
> proper KVO messages are posted whenever the property is changed, which
> is important for bindings. These methods will also be invoked
> directly by bindings (since they use -mutableArrayValueForKey:) making
> them more efficient.
I encourage folks to NOT start pushing KVO, KVC, etc. on folks that
are new to Cocoa development. ...especially in the abstract since we
have little visibility into the intent of the Classes involved so the
support of KVO/KVC may make little sense.
-Shawn
_______________________________________________
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