Re: KVO question
Re: KVO question
- Subject: Re: KVO question
- From: Quincey Morris <email@hidden>
- Date: Tue, 17 Nov 2015 23:43:36 -0800
- Feedback-id: 167118m:167118agrif8a:167118s8TCShQH_v:SMTPCORP
On Nov 17, 2015, at 17:18 , Graham Cox <email@hidden> 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@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