UndoRecorder
Swift
@objc(PSPDFUndoRecorder)
public protocol UndoRecorder
A type yielded by an undo controller that allows recording multiple undoable actions grouped as one undoable command.
PSPDF_EXPORT(PSPDFUndoRecorder)
-
Record actions of changing multiple properties of the given annotations by observing changes made to them in the scope of the given closure.
recorder.record(changing: [freeTextAnnotation]) { freeTextAnnotation.fontSize = 32 freeTextAnnotation.sizeToFit() }
The above code will record two actions for
freeTextAnnotation
: one forfontAttributes
, which changes as a result of settingfontSize
, and one forboundingBox
, which changes as result of callingsizeToFit()
.Precondition
Recording new actions in an already committed recorder is not allowed and will result in an assertion failure.
Precondition
Each of the given annotations must already be referenced in a PDF document, otherwise they will be ignored.
Declaration
Swift
@objc(recordChangingAnnotations:inScope:) func record(changing annotations: [Annotation], in scope: () -> Void)
Parameters
annotations
Annotations expected to change.
scope
Closure in which annotations are changed.
-
Record actions of adding the given annotations to a document.
recorder.record(adding: [lineAnnotation, circleAnnotation]) { document.add(annotations: [lineAnnotation, circleAnnotation]) }
The above code will record two actions: one for adding
lineAnnotation
and one for addingcircleAnnotation
.Precondition
Recording new actions in an already committed recorder is not allowed and will result in an assertion failure.
Declaration
Swift
@objc(recordAddingAnnotations:inScope:) func record(adding annotations: [Annotation], in scope: () -> Void)
Parameters
annotations
Annotations expected to be added.
scope
Closure in which annotations are added to a document.
-
Record actions of removing the given annotations from a document.
recorder.record(removing: [noteAnnotation, inkAnnotation]) { document.remove(annotations: [noteAnnotation, inkAnnotation]) }
The above code will record two actions: one for removing
noteAnnotation
and one for removinginkAnnotation
.Precondition
Recording new actions in an already committed recorder is not allowed and will result in an assertion failure.
Declaration
Swift
@objc(recordRemovingAnnotations:inScope:) func record(removing annotations: [Annotation], in scope: () -> Void)
Parameters
annotations
Annotations expected to be removed.
scope
Closure in which annotations are removed from a document.