A general-purpose recorder of operations that enables undo and redo.
- iOS 3.0+
- macOS 10.0+
- tvOS 9.0+
- watchOS 2.0+
You register an undo operation by specifying the object that’s changing (or the owner of that object), along with a method to invoke to revert its state, and the arguments for that method. When performing undo an
NSUndo saves the operations reverted so that you can redo the undos.
NSUndo is implemented as a class of the Foundation framework because executables other than applications might want to revert changes to their states. For example, you might have an interactive command-line tool with undo and redo commands, or there could be distributed object implementations that can revert operations “over the wire.” However, users typically see undo and redo as application features. UIKit implements undo and redo in its text view object and makes it easy to implement it in objects along the responder chain (see