Adding Undo Support
Cocoa Touch offers the NSUndoManager
class to provide a way to reverse user actions. By default, every application window provides a shared undo manager. You can use this shared manager or create your own.
All children of the UIResponder
class can find the nearest undo manager in the responder chain. This means that if you use the window’s undo manager in your view controller, the controller automatically knows about that manager through its undoManager
property. This is enormously convenient because you can add undo support in your main view controller, and all your child views basically pick up that support for free.
The manager can store an arbitrary number of undo actions. You may want to specify how deep that stack goes. ...
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.