I want to track an NSCountedSet to see if its contents are changing. KVO setup seems to be compiling but not starting up. First question: can you watch the set? If so, is there something wrong with this message?
[subViewA addObserver:subViewB forKeyPath:@"countedSet" options:0 context:NULL];
I'm just trying to control the count (number of objects) in the set if that helps.
Edit - here is the observer (subViewB):
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqual:@"countedSet"]) { NSLog(@"Set has changed"); } }
Edit2 - the addObserver message was moved from the sub-object to the viewController. Therefore, I am trying to get one subView to watch an NSCountedSet in another viewController submatrix. the "relative to the receiver" key path, which I suppose to be subViewA.
Meltemi
source share