UndoController
@objcMembers
@objc(PESDKUndoController)
open class UndoController : NSObject
UndoController
is a general-purpose recorder of operations for undo and redo.
Note
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 anUndoController
saves the operations reverted so that you can redo
the undos.
It differs from Foundation’s NSUndoManager
in that groups are not created automatically for
each cycle of the run loop and that each step of a group can be undone rather than just the
whole group.
-
A Boolean value that indicates whether the receiver is enabled and undo operations can be registered.
Declaration
Swift
open var isEnabled: Bool
-
Returns a Boolean value that indicates whether the receiver is in the process of performing its
undo()
,undoStep()
,undoStepInCurrentGroup()
,undoAllInCurrentGroup()
orundoGroup()
method.Declaration
Swift
open private(set) var isUndoing: Bool { get set }
-
Returns a Boolean value that indicates whether the receiver is in the process of performing its
redo()
method.Declaration
Swift
open private(set) var isRedoing: Bool { get set }
-
Marks the beginning of an undo group.
Declaration
Swift
open func beginUndoGrouping()
-
Marks the end of an undo group.
Declaration
Swift
open func endUndoGrouping()
-
Records a single undo operation for a given target, so that when an undo is performed the given handler with a given object as the sole argument is invoked.
Warning
This does not strongly retain the target. Care should be taken to avoid introducing retain cycles by other references captured by the block.Declaration
Swift
open func registerUndo<TargetType: AnyObject>(withTarget target: TargetType, handler undoHandler: @escaping (TargetType?) -> Void)
Parameters
target
The target of the undo operation.
undoHandler
The block to be executed for the undo operation.
-
Clears the undo and redo stacks.
Declaration
Swift
open func removeAllActions()
-
Clears the undo and redo stacks for the current group.
Declaration
Swift
open func removeAllActionsInCurrentGroup()
-
A Boolean value that indicates whether the receiver has any actions to undo.
Declaration
Swift
open var canUndo: Bool { get }
-
A Boolean value that indicates whether the receiver has any actions to undo in the current group.
Declaration
Swift
open var canUndoInCurrentGroup: Bool { get }
-
If the last undo operation on the undo stack is a group, this method performs the undo operations of the whole group, if it is a single operation it performs only that operation.
Declaration
Swift
open func undo()
-
Performs the latest undo operation only.
Declaration
Swift
open func undoStep()
-
Performs the latest undo operation in the current group. If the group contains a nested group it performs the undo operations of the whole nested group.
Declaration
Swift
open func undoStepInCurrentGroup()
-
Performs all undo operations in the current group.
Declaration
Swift
open func undoAllInCurrentGroup()
-
Performs the undo operations of the latest group. If the top item on the undo stack is not the ending of a group, this method throws an exception.
Declaration
Swift
open func undoGroup()
-
A Boolean value that indicates whether the receiver has any actions to redo.
Declaration
Swift
open var canRedo: Bool { get }
-
A Boolean value that indicates whether the receiver has any actions to redo in the current group.
Declaration
Swift
open var canRedoInCurrentGroup: Bool { get }
-
Performs the operations in the last group on the redo stack, if there are any, recording them on the undo stack as a single group.
Declaration
Swift
open func redo()