On Sep 10, 2012, at 19:29 , Rick Mann <rm...@latencyzero.com> 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 (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com