On Nov 17, 2015, at 17:18 , Graham Cox <[email protected]> wrote:
> 
> Mostly this is working, but when code directly sets the dictionary property, 
> the other properties don’t trigger their observers, even though I’m 
> implementing the +keyPathsForValuesAffecting<property>, which I believe 
> should cause the additional triggering. Have I understood that right?

It’s not clear. I can’t think of a compelling reason why the other observers 
shouldn’t trigger, but you are doing something a bit weird.

I wonder, also, if you’re always setting the ‘dictionaryOfThings’ property 
KVO-compliantly? In particular, is the instance variable perhaps changed 
initially from nil to an empty dictionary after there are already observers on 
the dictionary path?

As a matter of principle, I always think using a dictionary as an API to 
properties is a terrible idea. You’re much better off defining an object that 
actually has the properties, even if there are a lot of them. That would solve 
your difficulty here, since you wouldn’t need two ways of getting to the 
properties. Also, you’d avoid the danger inherent in exposing your mutable 
backing store (the NSMutableDictionary) to the outside world, always a 
prescription for trouble.

FWIW.


_______________________________________________

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]

Reply via email to