PSPDFUndoController


@interface PSPDFUndoController : 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 (readonly, getter=isWorking, nonatomic) BOOL working;

    Swift

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

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (readonly, getter=isRedoing, nonatomic) 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, nonatomic) 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, nonatomic) BOOL canRedo;

    Swift

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

    Declaration

    Objective-C

    - (void)undo;

    Swift

    func undo()
  • Performs a redo operation.

    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 PSPDFUndoProtocol to add support for conditional removal of PSPDFUndoProtocol 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<PSPDFUndoProtocol> *)object;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    func unregisterObject(forUndo object: PSPDFUndoProtocol)
  • Check if an object is already registered.

    Declaration

    Objective-C

    - (BOOL)isObjectRegisteredForUndo:(nonnull NSObject<PSPDFUndoProtocol> *)object;

    Swift

    func isObjectRegistered(forUndo object: PSPDFUndoProtocol) -> Bool
  • 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 (readonly, nonatomic) 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 (assign, readwrite, nonatomic) NSTimeInterval timedCoalescingInterval;

    Swift

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

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) NSUInteger levelsOfUndo;

    Swift

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

    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 (readonly, nonatomic) BOOL hasIncompleteUndoActions;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    var incompleteUndoActionName: String? { get }
  • Specifies whether undo is disabled globally.

    Declaration

    Objective-C

    @property (readonly, getter=isUndoEnabled, nonatomic) BOOL undoEnabled;

    Swift

    var isUndoEnabled: Bool { get }