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, or NO if an error occurred.

  • The PDF annotation represented by this view model.

    Note

    The default value of this property is nil.

    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 is 0.

    Declaration

    Objective-C

    @property (nonatomic, readonly) int pageNumber;

    Swift

    var pageNumber: Int32 { get }
  • The PDF document containing the represented annotation, or nil if there is no annotation.

    Note

    The default value of this property is nil.

    Declaration

    Objective-C

    @property (nonatomic, strong, readonly, nullable) PTPDFDoc *document;

    Swift

    var document: PTPDFDoc? { get }
  • The PTPDFAnnotationProperties subclass used for the PTAnnotationAppearanceViewModel.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 the PTAnnotationAppearanceViewModel.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, or NO if an error occurred.