Reputation: 351
I'm making an app and have a core data file with an entity and 15 boolean attributes. I want it so that when a user presses a button it changes the value of one of the attributes from "0" to "1" in the core data file. What is the code to do this? I already have the action set up.
Upvotes: 2
Views: 194
Reputation: 80265
-(void)buttonAction:(id)sender {
myManagedObject.boolAttribute = [NSNumber numberWithBool:
![myManagedObject.boolAttribute boolValue]];
[self.managedObjectContext save:nil];
// if you need to update the UI (no fetchedResultsController):
[self.view setNeedsDisplay];
// or
[self.tableView reloadData];
}
Upvotes: 1