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 calling one of the methods described in Registering Undo Operations. You specify the name of the object that’s changing (or the owner of that object) and provide a closure, method, or invocation to revert its state.
After you register an undo operation, you can call
undo on the undo manager to revert to the state of the last undo operation. When undoing an action,
NSUndo saves the operations you reverted to so that you can call
NSUndo is typically used by apps with UI interactions. For example, UIKit implements undo and redo in its text view object, making it easy for you to undo and redo actions in objects along the responder chain.
NSUndo also serves as a general-purpose state manager, which can be used to undo and redo many kinds of actions. For example, an interactive command-line utility could use this class to undo the last command run, or a networking library could undo a request by sending another request that invalidates the previous one.