On Jan 21, 2009, at 00:06, Ken Thomases wrote:

On Jan 19, 2009, at 7:25 PM, Quincey Morris wrote:

If anyone can find a place in any documentation or header files that *says* the indexed to-many accessors (such as insertObject:in<Key>AtIndex: and removeObjectFrom<Key>AtIndex:) are KVO-compliant when used directly, you'd be doing a public service by posting a link.

While researching an answer for a different thread, I found it:

Ah, thanks for finding it. :) I'm working up to submitting a documentation bug report, but the whole subject is (TBH) kind of of messily documented, and I haven't quite worked out yet what I want to complain about.

The description of NSKeyValueChangeKindKey in the NSKeyValueObserving protocol reference[1] says that:

A value of NSKeyValueChangeInsertion, NSKeyValueChangeRemoval, or NSKeyValueChangeReplacement indicates that mutating messages have been sent to the array returned by a mutableArrayValueForKey: message sent to the object, or that one of the key-value-coding- compliant array mutation methods for the key has been invoked, or that willChange:valuesAtIndexes:forKey:/ didChange:valuesAtIndexes:forKey: has otherwise been invoked.

It documents that "the key-value-coding-compliant array mutation methods" generate change notifications of one of those kinds. Further, it makes clear, by implication, that KVO does this by hooking into those methods when a property is being observed and invoking will/didChange:valuesAtIndexes:forKey: within its overrides.

I wondered about this, too, though I came up with some reason (which I've now forgotten) for thinking that the accessor overrides did *not* go through will/didChange. If they do, it should be possible to override all 6 will/didChange methods themselves, and watch *all* KVO notifications being sent. I guess that's testable easily enough.


_______________________________________________

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to