PTAnnotationAppearanceViewModel
@interface PTAnnotationAppearanceViewModel<
AnnotationType : PTAnnot *, PropertiesType : PTPDFAnnotationProperties *>
: NSObject
A representation of a PDF annotation.
The class is parameterized by the annotation and properties types which must be subclasses of
the PTAnnot
and PTPDFAnnotationProperties
classes, respectively.
-
Initializes a
PTAnnotationAppearanceViewModel
instance.Declaration
Objective-C
- (nonnull instancetype)init;
Swift
init()
Return Value
An initialized
PTAnnotationAppearanceViewModel
instance. -
Configures the view model with the specified annotation.
Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)configureWithAnnotation:(nonnull AnnotationType)annotation onPageNumber:(int)pageNumber inDocument:(nullable PTPDFDoc *)document error:(out NSError *_Nullable *_Nullable)outError;
Swift
func configure(withAnnotation annotation: AnnotationType, onPageNumber pageNumber: Int32, inDocument document: PTPDFDoc?) throws
Parameters
annotation
The PDF annotation.
pageNumber
The number of the PDF page containing the annotation in the document.
document
The PDF document, or
nil
.outError
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify
nil
for this parameter if you do not want the error information.Return Value
YES
if the view model was configured, orNO
if an error occurred. -
The PDF annotation represented by this view model.
Note
The default value of this property isnil
.Declaration
Objective-C
@property (nonatomic, strong, readonly, nullable) AnnotationType annotation;
Swift
var annotation: AnnotationType? { get }
-
The number of the PDF page containing the represented annotation, or
0
if there is no annotation.Note
The default value of this property is0
.Declaration
Objective-C
@property (nonatomic, readonly) int pageNumber;
Swift
var pageNumber: Int32 { get }
-
The properties for the represented annotation.
Declaration
Objective-C
@property (nonatomic, strong, readonly) PropertiesType _Nonnull properties;
Swift
var properties: PropertiesType { get }
-
The state of the represented annotation.
Declaration
Objective-C
@property (nonatomic, strong, readonly) PTPDFAnnotationState *_Nonnull state;
Swift
var state: PTPDFAnnotationState { get }
-
The
PTPDFAnnotationProperties
subclass used for thePTAnnotationAppearanceViewModel.properties
instance property.Subclasses of
PTAnnotationAppearanceViewModel
should override this class property to return the appropriate annotation properties class.Note
The default value of this property is the
PTPDFAnnotationProperties
class.Declaration
Objective-C
@property (class, nonatomic, strong, readonly) Class _Nonnull propertiesClass;
Swift
class var propertiesClass: AnyClass { get }
-
The
PTPDFAnnotationState
subclass used for thePTAnnotationAppearanceViewModel.state
instance property.Subclasses of
PTAnnotationAppearanceViewModel
should override this class property to return the appropriate annotation state class.Note
The default value of this property is the
PTPDFAnnotationState
class.Declaration
Objective-C
@property (class, nonatomic, strong, readonly) Class _Nonnull stateClass;
Swift
class var stateClass: AnyClass { get }
-
Updates the view model from the represented annotation.
Subclasses of
PTAnnotationAppearanceViewModel
should override this method to update any state dependent on the annotation.Note
In Swift, this method is imported as a throwing function.
Declaration
Objective-C
- (BOOL)updateWithError:(out NSError *_Nullable *_Nullable)outError;
Swift
func update() throws
Parameters
outError
On input, a pointer to an error object. If an error occurs, this pointer is set to an actual error object containing the error information. You may specify
nil
for this parameter if you do not want the error information.Return Value
YES
if the view model was updated, orNO
if an error occurred.