I have an object data of class EquationData. I also have a custom tableviewcell (balanceCell), which has as a subview a custom text field (balanceCell.leftView). The text field has a property of type NSMutableString equationOrder which changes as the user types in text. I want data to receive notifications as more objects are added to equationOrder.
What I have in the view controller
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
equationCell = (EquationCell *) [tableView dequeueReusableCellWithIdentifier:@"equationCell"];
if (equationCell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"EquationCell" owner:self options:nil];
equationCell = (EquationCell*) [nib objectAtIndex:0];
[equationCell.leftView addObserver:data forKeyPath:@"equationOrder" options:NSKeyValueObservingOptionNew context:nil];
}
return equationCell;
}
What I have in data's implementation
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"equationOrder"])
NSLog(@"called");
}
However, "called" is not displayed on the screen. I have tried using other variables for data to observe, and I've tried changing equationOrder from a property to just a variable.
How do I get data to receive notifications as equationOrder is changed? (I've made sure that objects are actually added to equationOrder)