Hey Guys -
So I'm using core data to hold my data, then displaying it in a tableview, etc. And yet I'm having this really weird problem that I cant figure out. The items have a property called health thats defined in the model as an int 16, and so its a NSNumber in the class, which is all fine. But when I try to set it, it doesnt work, and then when I log the health, I get crazy results like 99990453 that dont make any sense. Idk whats Wrong! Code -
Code:
NSLog(@"Plus");
NSLog(@"%d", self.currentSelectedIndexPath.row);
Item *editItem = [itemArray objectAtIndex:self.currentSelectedIndexPath.row];
editItem.health = [NSNumber numberWithInt:1];
NSLog(@"New Health: %d", editItem.health);
NSManagedObject *editedObject = editItem;
[managedObjectContext refreshObject:editedObject mergeChanges:YES];
NSError *error;
if (![managedObjectContext save:&error]) {
//Handle Error
}
[editItem release];
Also while Ive got you here, is this the correct way to save the object after i edited it? i couldnt really find a description of how to do that in the docs...
Thx!