Key-Value-Observing and Collections
Philip Mötteli
Philip.Moetteli at tele2.ch
Thu Oct 25 06:23:51 PDT 2007
Hi,
There is something, I just don't get with KVO. Lets say, I have an
object
@interface Pupil
{
NSMutableArray grades;
}
- (void)setGrades:(NSMutableArray *)theGrades;
- (NSMutableArray *)grades;
- (void)addGrade:(Grade *)aGrade;
@end
Using KVO, I want to be notified not only, when the old grades
collection object (NSMutableArray) is replaced, but also, when a
Grade instance is added to the grades array (something like "[grades
addObject:aGrade]").
The first case is easy, because I know the attribute name (grades),
which gives the key. But for the second, I don't know the attribute
name, so I can't add an observer.
Can anybody explain me how to do this?
Thanks
Phil
More information about the MacOSX-dev
mailing list