On Oct 5, 2009, at 11:54, Stuart Malin wrote:

An NSMutableArray is not KVO compliant for addition and deletion of entries. You must either provide manual notification or create a class with a To-Many property that is KVO compliant.

From the "Key Value Observing Programming Guide" --

Automatic notification is also supported for the collection proxy objects returned by mutableArrayValueForKey: and mutableSetValueForKey: . This works for to-many relationships that support the indexed accessor methods insertObject:in<Key>AtIndex:,replaceObjectIn<Key>AtIndex:, and removeObjectFrom<Key>AtIndex:.

Except that, although your first paragraph is correct as far as it goes, it's not the whole answer.

You can use the mutable array proxy for an array property that is *not* implemented with the indexed accessor methods. They're sort of irrelevant to the problem.

You can also replace the entire array, but KVO compliantly via KVC of course, without being concerned with either mutable proxies or indexed accessors. This is the brute force method, though, so it's often not the best way. (Someone suggested this solution earlier in the thread, but seemed to be saying that it was the *only* option, which isn't so.)


_______________________________________________

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

This email sent to [email protected]

Reply via email to