KVO. ObserveValueForKeyPAth is not called

时间:2015-06-15 14:33:32

标签: objective-c nsmutablearray key-value-observing

I am not if this will work properly

[[cr1.crossRoad.trafficLights 
    objectForKey: [NSNumber numberWithInt:pedestrianTL]] 
    addObserver:view 
    forKeyPath:@"colorState" 
    options:NSKeyValueObservingOptionNew 
    context:nil];

The project I'm developing doesn't work properly. This way I was trying to add an observer to change the view with after every change happening to the cell of the colorState array.

-(void) observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    [self refreshState:object];
}

The program never enters this method though I change values of the colorState cells. Maybe the problem is with me trying to observe array but not actually what it contains?

1 个答案:

答案 0 :(得分:0)

问题在于我试图观察一个不可能的阵列。