私はアプリを作成しており、エンティティと 15 のブール属性を含むコア データ ファイルがあります。ユーザーがボタンを押すと、コア データ ファイル内のいずれかの属性の値が「0」から「1」に変更されるようにします。これを行うコードは何ですか?すでにアクションを設定しています。
1 に答える
            1        
        
		
-(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];
}
    于 2012-08-03T19:49:19.010   に答える