O'Reilly logo

Cocoa in a Nutshell by James Duncan Davidson, Michael Beam

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

NSUndoManager — Mac OS X 10.0

Synopsis

This class provides the basis of Cocoa’s undo and redo system. NSUndoManager supports two kinds of undo: simple undo and invocation-based undo. In simple undo clients register in the undo manager a target and selector that is used to undo the last operation. In invocation based undo the client creates an NSInvocation object that can undo the last operation and record that in the undo manager. In either case, it is the responsibility of the client to specify how the an operation is undone; NSUndoManager simply provides the machinery for keeping track of and executing the supplied selectors or invocations.

image with no caption

@interface NSUndoManager : NSObject
                                  // Accessor Methods
   - (void)setActionName:(NSString *)actionName;
   - (void)setGroupsByEvent:(BOOL)groupsByEvent;
   - (BOOL)groupsByEvent;
   - (void)setRunLoopModes:(NSArray *)runLoopModes;
   - (NSArray *)runLoopModes;
   - (void)setLevelsOfUndo:(unsigned)levels;
   - (unsigned)levelsOfUndo;
                                  // Instance Methods
   - (void)beginUndoGrouping;
   - (BOOL)canRedo;
   - (BOOL)canUndo;
   - (void)disableUndoRegistration;
   - (void)enableUndoRegistration;
   - (void)endUndoGrouping;
   - (void)forwardInvocation:(NSInvocation *)anInvocation;
   - (int)groupingLevel;
   - (BOOL)isRedoing;
   - (BOOL)isUndoRegistrationEnabled;
   - (BOOL)isUndoing;
   - (id)prepareWithInvocationTarget:(id)target;
   - (void)redo;

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required