PSPDFUndoController

Objective-C


@interface PSPDFUndoController : NSObject

Swift

class UndoController : NSObject

This is a custom undo manager that can coalesce similar changes within the same group. This class is thread safe.

PSPDFKit creates instances of this class internally and makes them available on various objects. You should not create new instances of this class yourself.

Note

Only use a perform/lock block if you’re not in any other lock controlled by PSPDFKit.
  • Returns YES if the undo controller is currently either undoing or redoing.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isWorking) BOOL working;

    Swift

    var isWorking: Bool { get }
  • Returns YES if the undo controller is currently undoing.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isUndoing) BOOL undoing;

    Swift

    var isUndoing: Bool { get }
  • Returns YES if the undo controller is currently redoing.

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=isRedoing) BOOL redoing;

    Swift

    var isRedoing: Bool { get }
  • Returns YES if undoable operations have been recorded.

    Note

    This is a calculated property and does not support KVO. Listen to NSUndoManagerDid* and PSPDFUndoController* notification events instead.

    Declaration

    Objective-C

    @property (readonly) BOOL canUndo;

    Swift

    var canUndo: Bool { get }
  • Returns YES if recordable operations have been recorded.

    Note

    This is a calculated property and does not support KVO. Listen to NSUndoManagerDid* and PSPDFUndoController* notification events instead.

    Declaration

    Objective-C

    @property (readonly) BOOL canRedo;

    Swift

    var canRedo: Bool { get }
  • Performs an undo operation.

    Note

    If undo is not possible, this is a NOP.

    Declaration

    Objective-C

    - (void)undo;

    Swift

    func undo()
  • Performs a redo operation.

    Note

    If redo is not possible, this is a NOP.

    Declaration

    Objective-C

    - (void)redo;

    Swift

    func redo()
  • Helper that will infer a good name for changedProperty of object.

    Declaration

    Objective-C

    - (void)endUndoGroupingWithProperty:(nonnull NSString *)changedProperty
                               ofObject:(nullable id)object;

    Swift

    func endUndoGrouping(withProperty changedProperty: String, of object: Any?)
  • Removes all recorded actions.

    Declaration

    Objective-C

    - (void)removeAllActions;

    Swift

    func removeAllActions()
  • Removes all recorded actions with the provided target. Implement performUndoAction: from PSPDFUndoSupport to add support for conditional removal of PSPDFUndoSupport tracked (observed) changes.

    Declaration

    Objective-C

    - (void)removeAllActionsWithTarget:(nonnull id)target;

    Swift

    func removeAllActions(withTarget target: Any)
  • Register an object.

    Declaration

    Objective-C

    - (void)registerObjectForUndo:(nonnull NSObject<PSPDFUndoSupport> *)object;

    Swift

    func registerObject(forUndo object: UndoSupport)
  • Unregister an object.

    Declaration

    Objective-C

    - (void)unregisterObjectForUndo:(nonnull NSObject<PSPDFUndoSupport> *)object;

    Swift

    func unregisterObject(forUndo object: UndoSupport)
  • Support for regular invocation based undo. Perform the call you would normally invoke after [undoManager prepareWithInvocationTarget:target] on the proxy passed into the block.

    Declaration

    Objective-C

    - (void)prepareWithInvocationTarget:(nonnull id)target
                                  block:(nonnull void (^)(id _Nonnull))block;

    Swift

    func prepare(withInvocationTarget target: Any, block: @escaping (Any) -> Void)
  • Provides access to the underlying NSUndoManager. You are strongly encouraged to not use this property since it is not thread safe and PSPDFUndoController manages the state of this undo manager. However, since UIResponders can provide an undo manager, this property is exposed.

    Declaration

    Objective-C

    @property (nonatomic, readonly) NSUndoManager *_Nonnull undoManager;

    Swift

    var undoManager: UndoManager { get }
  • Specifies the time interval that is used for PSPDFUndoCoalescingTimed. Defaults to 0.5 seconds.

    Declaration

    Objective-C

    @property (nonatomic) NSTimeInterval timedCoalescingInterval;

    Swift

    var timedCoalescingInterval: TimeInterval { get set }
  • Specifies the levels of undo we allow. Defaults to 100. More means higher memory usage.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger levelsOfUndo;

    Swift

    var levelsOfUndo: UInt { get set }
  • Required for conditional undo removal support using removeAllActionsWithTarget:.

    See

    PSPDFUndoSupport

    Declaration

    Objective-C

    - (void)performUndoAction:(nonnull PSPDFUndoAction *)action;

    Swift

    func perform(_ action: PSPDFUndoAction)
  • Commits all incomplete undo actions. This method is automatically called before undoing or redoing, so there’s usually no need to call this method directly.

    Declaration

    Objective-C

    - (void)commitIncompleteUndoActions;

    Swift

    func commitIncompleteUndoActions()
  • Indicates that there are still incomplete undo actions because of a coalescing policy.

    Declaration

    Objective-C

    @property (nonatomic, readonly) BOOL hasIncompleteUndoActions;

    Swift

    var hasIncompleteUndoActions: Bool { get }
  • Returns the name of the most recent incomplete action or nil.

    Declaration

    Objective-C

    @property (nonatomic, readonly, nullable) NSString *incompleteUndoActionName;

    Swift

    var incompleteUndoActionName: String? { get }