PSPDFUndoProtocol

@protocol PSPDFUndoProtocol <NSObject>

Implement on model objects that should allow undo/redo.

  • Keys that should be KVO observed. Observed collections will be deeply introspected. - warning: Only observe collections of type NSSet, NSOrderedSet and NSArray. - warning: Do not change the result of this method dynamically.

    Declaration

    Objective-C

    + (nonnull NSSet<NSString *> *)keysForValuesToObserveForUndo;

    Swift

    static func keysForValuesToObserveForUndo() -> Set
  • Returns the localized undo action name for a given key. - note: If this method is not implemented or returns nil, the name of the key is used.

    Declaration

    Objective-C

    + (nullable NSString *)localizedUndoActionNameForKey:(nonnull NSString *)key;

    Swift

    optional static func localizedUndoActionName(forKey key: String) -> String?
  • Returns the coalescing for a given key. - note: If this method is not implemented, PSPDFUndoCoalescingNone will be used for all keys. - warning: Do not change the result of this method dynamically.

    Declaration

    Objective-C

    + (PSPDFUndoCoalescing)undoCoalescingForKey:(nonnull NSString *)key;

    Swift

    optional static func undoCoalescing(forKey key: String) -> PSPDFUndoCoalescing
  • Required when observing collections. It is your responsibility to update the affected collection. - note: The index of an element is not preserved, so the order of elements in a collection might change during an undo operation. - warning: It is your responsibility to trigger appropriate KVO events when you insert or remove an object. The easiest way to do this is to call mutable<CollectionType>ValueForKey: on self and to modify that collection object.

    Declaration

    Objective-C

    - (void)insertUndoObjects:(nonnull NSSet *)objects
                       forKey:(nonnull NSString *)key;

    Swift

    optional func insertUndoObjects(_ objects: Set
  • Undocumented

    Declaration

    Objective-C

    @protocol PSPDFUndoProtocol <NSObject>
  • Called when changes caused by an undo or redo were applied to an object.

    Declaration

    Objective-C

    - (void)didUndoOrRedoChange:(nonnull NSString *)key;

    Swift

    optional func didUndoOrRedoChange(_ key: String)
  • Required for conditional undo removal support. Implementing this method makes sure the internal undo manager records the correct target object, so we’re able to use removeAllActionsWithTarget: for undo removal, by passing in self as the method parameter. Your implementation should pass the action parameter through to-[PSPDFUndoController performUndoAction:]`.

    Declaration

    Objective-C

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

    Swift

    optional func perform(_ action: PSPDFUndoAction)