【发布时间】:2012-08-01 19:57:48
【问题描述】:
我正在制作一个应用程序,并且有一个包含一个实体和 15 个布尔属性的核心数据文件。我想要它,以便当用户按下按钮时,它会将核心数据文件中属性之一的值从“0”更改为“1”。执行此操作的代码是什么?我已经设置了动作。
【问题讨论】:
标签: ios xcode core-data attributes boolean
我正在制作一个应用程序,并且有一个包含一个实体和 15 个布尔属性的核心数据文件。我想要它,以便当用户按下按钮时,它会将核心数据文件中属性之一的值从“0”更改为“1”。执行此操作的代码是什么?我已经设置了动作。
【问题讨论】:
标签: ios xcode core-data attributes boolean
-(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];
}
【讨论】: