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 13:49:57 -0700
On May 12, 2010, at 13:07, Ken Thomases wrote:
> There's no such thing as updating arrays or sets KVO-compliantly. (Again, I speak in terms of their elements, not properties like count or description.) You can only update to-many relationship properties of some other object, which _might_ be backed by arrays or sets.
Beg pardon, you're exactly correct, it was my early morning brain freeze, in part.
Here's what I was actually thinking of:
Assume you have some array that is the value of some object's array property, and that the property is mutable (though the array you have in hand need not be). If you want to "change the array" and have notifications be triggered, you must get a mutable array proxy "for the array" and modify that instead. That's kind of what I was talking about, though it's a loose way of speaking (and I'm sorry I did it).
As you've already replied, there's no certainty that an array property is backed by any actual array at all, but there are two important and frequent cases where in fact "you have some array that is the value of some object's array property":
1. If the class with the property can return a NSArray that represents the value of the property (even if the property is not backed by an array internally). That is, if a plain getter for the property exists, and that's true in the vast majority of cases.
2. Within the class implementation, when the property is in fact backed by a NS(Mutable)Array instance variable. In that case, if you (the class implementer) want to change the array ivar, and you want to "change it KVO compliantly", you must get a mutable proxy.
In both cases, there's a meaningful informal sense to "changing an array KVO-compliantly", and that's what I was focused on.
Sorry for missing your essential point, though.
_______________________________________________
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