2012-08-03 121 views
2

我正在製作一個應用程序,並擁有一個具有實體和15個布爾屬性的核心數據文件。我希望這樣,當用戶按下按鈕時,它會將核心數據文件中某個屬性的值從「0」更改爲「1」。這是什麼代碼?我已經設置了行動。Xcode核心數據屬性

回答

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]; 
} 
+0

感謝這有助於很多 – chrisl212 2012-08-03 20:04:14