Re: Arghh bindings
Re: Arghh bindings
- Subject: Re: Arghh bindings
- From: Quincey Morris <email@hidden>
- Date: Mon, 10 Sep 2012 19:52:05 -0700
On Sep 10, 2012, at 19:29 , Rick Mann <email@hidden> wrote:
> The docs say this is all for KVC compliance. But because the calls are almost one-to-one when backed by a simple collection, I'm surprised they don't do it for me.
>
> In other words, I could write code to dynamically implement -insert<Key>:atIndexes: given a mutable array named <Key>.
It's not quite the same situation as a regular synthesized setter. Omitting a scalar property accessor causes a link error. The KVC part works (assuming a NSMutableArray ivar) without needing any code. The KVO part works too without code, BTW, if you use the mutable array proxy. IOW, synthesizing anything doesn't really buy you much.
> 1. It avoids letting KVC introspect your ivars, which is a horrible hack.
>
> Not sure I agree here.
You're effectively making the ivar public. Any client of the class can use 'setValue:forKey:' (or a mutable indexed accessor) to change the array arbitrarily. Implementing the accessors yourself gives you the opportunity to have access checks. (Or, in some cases, not implementing the accessors -- in conjunction with disabling automatic ivar access for the class -- to prevent clients from changing the property.)
_______________________________________________
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