I want to disable undo registration for an operation on an NSManagedObject but it still records the operation even though I explicitly call disableUndoRegistration.
Is there something obvious I am missing?
I also tried to enable/disable in the viewWillAppear and viewWillDisappear methods, respectively.
Here is some example code...
#pragma mark -
#pragma mark NotesViewControllerDelegate methods
- (void)notesViewController:(NotesViewController *)controller didFinishWithSave:(BOOL)save
{
开发者_StackOverflow中文版 if (save)
{
[undoManager disableUndoRegistration];
[book setNotes:[controller getDataFromText]];
[undoManager enableUndoRegistration];
}
}
You have to call [managedObjectContext processPendingChanges]; before each of the calls that disable and enable the undo registration because Core Data queues changes to be able to do optimizations.
see http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOs.html
精彩评论