here's my NSArray
carType (
{
isSelected = 0;
kFieldName = "All types";
kObjectValue = 0;
kObjectValueText = All;
},
{
isSelected = 0;
kFieldName = "4 seats";
kObjectValue = 4;
kObjectValueText = "4 seats";
},
{
isSelected = 1;
kFieldName = "7 seats";
kObjectValue = 7;
kObjectValueText = "7 seats";
}
)
how can I observe the change of isSelected
field ?
I used KVO in my code but it doesn't work.
carType
is a NSArray
property of context
- (void)viewDidLoad
{
[super viewDidLoad];
[context addObserver:self forKeyPath:@"carType" options:NSKeyValueObservingOptionNew context:NULL];
}
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
if ([keyPath isEqualToString:@"carType"]) {
NSLog(@"carType changed");
}
}
//dealloc remove observer