core-dataxcode8macos-sierransundomanager

How to use NSUndoManager on macOS 10.12?


I read in the documentation that NSManagedObjectContext now defaults to a nil NSUndoManager on macOS. How can I set NSUndoManager?


Solution

  • Create an undo manager and assign it to the managed object context.

    NSUndoManager *undoManager = [[NSUndoManager alloc] init];
    managedObjectContext.undoManager = undoManager;