开发者

disableUndoRegistration is still allowing undo operations

开发者 https://www.devze.com 2023-02-07 15:24 出处:网络
I want to disable undo registration for an operation on an NSManagedObject but it still records the operation even though I explicitly call disableUndoRegistration.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号