Adding Undo/Redo Support

Core Data simplifies table undo/redo support to an astonishing degree. It provides automatic support for these operations and requires little programming effort. Add this support by assigning an undo manager when you create a Core Data context:

_context = [[NSManagedObjectContext alloc] init]; _context.persistentStoreCoordinator = persistentStoreCoordinator; _context.undoManager = [[NSUndoManager alloc] init]; _context.undoManager.levelsOfUndo = 999;

As with all other undo/redo support, your primary controller must become the first responder while it is onscreen. The standard suite of first responder methods includes canBecomeFirstResponder (respond YES), viewDidAppear: (the controller view ...

Get The Core iOS Developer’s Cookbook, Fifth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.