Re: Question about model observers
Re: Question about model observers
- Subject: Re: Question about model observers
- From: Quincey Morris <email@hidden>
- Date: Wed, 12 May 2010 12:39:50 -0700
On May 12, 2010, at 11:04, Ken Thomases wrote:
> On May 12, 2010, at 11:44 AM, Quincey Morris wrote:
>
>> *All* collections emit KVO notifications when their contents change, in the sense of objects entering or leaving the collection. Add, remove and replace for arrays, add and remove for sets, set and remove for dictionaries.
>
> Arrays and sets may (probably; I haven't checked) emit change notifications for their "count" and "description" properties when elements are added or removed. But they don't emit change notifications regarding the specific elements that they contain, which is what I think Keary was getting at. In particular, they don't emit a change notification of kind NSKeyValueChangeInsertion, NSKeyValueChangeRemoval, or NSKeyValueChangeReplacement.
Well, technically, they don't *emit* these notifications -- they are emitted by KVO-compliant custom accessors and/or KVO-compliant mutable array/set proxies.
I have no idea whether NSMutableDictionary does literally emit (will/DidChange...) notifications for setObject:forKey:/removeObjectForKey:, or whether those methods are invisibly wrapped in KVO-compliant methods, just like ordinary object properties when they're observed.
Either way, I'm not sure it matters a lot where the notifications come from. My point was that KVO notifications of kind NSKeyValueChangeInsertion, NSKeyValueChangeRemoval, or NSKeyValueChangeReplacement do happen when arrays and sets are updated KVO-compliantly, just like KVO notifications of kind NSKeyValueChangeSetting happen when ordinary object properties are updated KVO-compliantly.
_______________________________________________
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