PSPDFGalleryItem


@interface PSPDFGalleryItem : NSObject

The abstract class for an item in a gallery. Most items will have content that needs to be loaded, hence this class allows for asynchronous state changes. It is the responsibility of the subclass to implement loading, for example by implementing the PSPDFRemoteContentObject protocol.

  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFGalleryItem : NSObject
  • Undocumented

    Declaration

    Objective-C

    
    @interface PSPDFGalleryItem : NSObject
  • The content URL of the item.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic) NSURL *_Nonnull contentURL;

    Swift

    var contentURL: URL { get }
  • The caption of the item.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable) NSString *caption;

    Swift

    var caption: String? { get }
  • The options dictionary of the item. Subclasses should implement dedicated setters to access the supported options.

    Declaration

    Objective-C

    @property (readonly, copy, nonatomic, nullable)
        NSDictionary<NSString *, id> *options;

    Swift

    var options: [String : Any]? { get }
  • The state of the item’s content. Defaults to PSPDFGalleryItemContentStateWaiting.

    Declaration

    Objective-C

    @property (readonly, nonatomic) PSPDFGalleryItemContentState contentState;

    Swift

    var contentState: PSPDFGalleryItemContentState { get set }
  • The content of the item. Defaults to nil.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) id content;

    Swift

    var content: Any? { get set }
  • Indicates if the content of contentURL is considered valid.

    Declaration

    Objective-C

    @property (readonly, getter=hasValidContent, nonatomic) BOOL validContent;

    Swift

    var hasValidContent: Bool { get }
  • The error that occurred while loading the content. Only valid if contentState is PSPDFGalleryItemContentStateError. - note: This property is not related to the error pointer that can be provided when creating an PSPDFGalleryItem.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nullable) NSError *error;

    Swift

    var error: Error? { get }
  • The progress of loading the content. Only valid if contentState is PSPDFGalleryItemContentStateLoading.

    Declaration

    Objective-C

    @property (readonly, nonatomic) CGFloat progress;

    Swift

    var progress: CGFloat { get }
  • Factory method to create an array of items from JSON data. Returns nil in case of an error. - warning: This method may return unresolved gallery items of type PSPDFGalleryUnknownItem. It may also not support all features of the gallery. You are strongly encouraged to use PSPDFGalleryManifest to instantiate gallery items!

    Declaration

    Objective-C

    + (nullable NSArray<PSPDFGalleryItem *> *)
    itemsFromJSONData:(nonnull NSData *)data
                error:(NSError *_Nullable *_Nullable)error;

    Swift

    class func items(fromJSONData data: Data) throws -> [PSPDFGalleryItem]
  • Factory method that creates a single gallery item directly from a link annotation. Returns nil in case of an error. - warning: This method may return unresolved gallery item of type PSPDFGalleryUnknownItem. It may also not support all features of the gallery. You are strongly encouraged to use PSPDFGalleryManifest to instantiate gallery items!

    Declaration

    Objective-C

    + (nullable PSPDFGalleryItem *)
    itemFromLinkAnnotation:(nonnull PSPDFLinkAnnotation *)annotation
                     error:(NSError *_Nullable *_Nullable)error;

    Swift

    /*not inherited*/ init(from annotation: PSPDFLinkAnnotation) throws
  • Creates an item from a given dictionary. The dictionary will usually be parsed JSON. - warning: This method triggers an assertion if contentURL is invalid. - note: This is the designated initializer.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithDictionary:
        (nonnull NSDictionary<NSString *, id> *)dictionary;

    Swift

    init(dictionary: [String : Any])
  • Creates an item with the given contentURL, caption and options. contentURL is required. option takes PSPDFGalleryItem* keys.

    Declaration

    Objective-C

    - (nonnull instancetype)
    initWithContentURL:(nonnull NSURL *)contentURL
               caption:(nullable NSString *)caption
               options:(nullable NSDictionary<NSString *, id> *)options;

    Swift

    convenience init(contentURL: URL, caption: String?, options: [String : Any]? = nil)
  • Indicates if the playback controls should be visible. Defaults to YES.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) BOOL controlsEnabled;

    Swift

    var controlsEnabled: Bool { get set }
  • Indicates if the content can be presented fullscreen. Defaults to YES.

    Declaration

    Objective-C

    @property (getter=isFullscreenEnabled, assign, readwrite, nonatomic)
        BOOL fullscreenEnabled;

    Swift

    var isFullscreenEnabled: Bool { get set }