PSPDFGalleryItem

Objective-C


@interface PSPDFGalleryItem : NSObject

Swift

class GalleryItem : 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.

  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • Unavailable

    Not the designated initializer

    Undocumented

    Declaration

    Objective-C

    PSPDF_EMPTY_INIT_UNAVAILABLE
  • The content URL of the item.

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly, 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 (nonatomic, readonly) NSDictionary<PSPDFGalleryOption, id> *_Nonnull options;

    Swift

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

    See more

    Declaration

    Objective-C

    @property (nonatomic, readonly) PSPDFGalleryItemContentState contentState;

    Swift

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

    See more

    Declaration

    Objective-C

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

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly, getter=hasValidContent) 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 (nonatomic, readonly, nullable) NSError *error;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic, readonly) 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 -> [GalleryItem]
  • 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<PSPDFGalleryItemProperty, id> *)dictionary;

    Swift

    init(dictionary: [GalleryItem.Property : 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<PSPDFGalleryOption, id> *)options;

    Swift

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

    Declaration

    Objective-C

    @property (nonatomic) BOOL controlsEnabled;

    Swift

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

    Declaration

    Objective-C

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

    Swift

    var isFullscreenEnabled: Bool { get set }