I am trying to get key-value-observing to work for an NSMutableArray. Below is the .h file for MyObservee, the observed class:
@interface MyObservee : NSObject {
@private int someValue;
@private NSMutableArray *someArray;
}
@property (readwrite,assign) int someValue;
- (NSMutableArray *)someArray;
@end
The class MyObserver implements observeValueForKeyPath:ofObject:change:context:. Here is how I add the observer:
MyObservee *moe = [[MyObservee alloc] init];
MyObserver *mobs = [[MyObserver alloc] init];
[moe addObserver:mobs
forKeyPath:@"someArray"
options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld)
context:NULL];
[[moe someArray] addObject:@"hi there"];
How come the addObject: message isn't triggering as a change to the someArray key path? I have a feeling there's something I don't fully understand here.