On Jul 11, 2012, at 9:28 AM, Ken Thomases wrote: > On Jul 11, 2012, at 1:45 AM, Quincey Morris wrote: > >> **** There isn't AFAIK a really easy way to prevent clients that aren't >> supposed to mutate the property from just invoking 'mutableArrayValueForKey: >> @"<key>"' by themselves.
> Another approach is to just define a single property. Instead of > implementing the KVC-compliant indexed accessor mutation methods, implement > variants with a slightly non-conformant name (perhaps with a prefix of > "private"). Then have those manually emit the proper KVO change > notifications by invoking -will/didChange:valuesAtIndexes:forKey:. Use those > private methods to mutate the property from within your own code. Oh, and I forgot to say: always, *always* override +accessInstanceVariablesDirectly to return NO in all of your classes. KVC's direct instance variable access is an encapsulation-violating abomination. Regards, Ken _______________________________________________ Cocoa-dev mailing list ([email protected]) 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 [email protected]
