Is it possible to update a value in the entity from the configure cell function? I want to change the value of an entries attribute if a number is greater than the other. This is what i have so far but it crashes the app with an error:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason:
'[<Outgoing 0x7fbcf3141890> setValue:forUndefinedKey:]: the entity Outgoing
is not key value coding-compliant for the key "goingover".'
MY configurecell method:
- (void)configureCell:(UITableViewCell *)cell atIndexPath:(NSIndexPath *)indexPath {
Outgoing *outgoing = [self.fetchedResultsController objectAtIndexPath:indexPath];
cell.textLabel.text = outgoing.costDescription;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%.2f",[outgoing.amount floatValue]];
if (self.incomingTotal > self.outgoingTotal) {
[outgoing setValue:@"no" forKey:@"goingover"];
}
if ([outgoing.goingOver isEqualToString:@"yes"]) {
cell.backgroundColor = [UIColor redColor];
}else{
cell.backgroundColor = [UIColor lightGrayColor];
}
}