KVO: Observing an aggregate property of a collection?
KVO: Observing an aggregate property of a collection?
- Subject: KVO: Observing an aggregate property of a collection?
- From: Jens Alfke <email@hidden>
- Date: Thu, 10 Jul 2008 14:46:29 -0700
How do I set up key-value observing of an aggregate property over an
array, like a sum?
Say I have a Bulb class with a boolean "lit" property. I have an
NSArrayController with an array of Bulbs, being shown in a table view.
To compute the number of lit bulbs I can do:
- (unsigned) litCount {
return [_bulbArrayController valueForKeyPath:
@"email@hidden"];
}
Now if I want to display this count in my UI, I need to get
notifications of when it changes. But what keypath do I observe? I've
tried "email@hidden", and I don't get
any exceptions, but the observer never triggers when I change the
"lit" property of a bulb in the array.
—Jens
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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