SBSDKUIPageFileStorage

@interface SBSDKUIPageFileStorage : NSObject

A class for storing and restoring images in a memory-efficient way. Stores added images on disk and restores them if requested. Can generate preview images of optimal resolution for the devices screen. Manages two types of images: original images (as from camera or photo library) and document images (cropped and perspective-corrected). Helps you efficiently managing and persisting larger images without keeping them in memory.

  • Not available. Use ‘defaultStorage’.

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • Not available. Use ‘defaultStorage’.

    Declaration

    Objective-C

    + (nonnull instancetype)new;
  • Initializes storage with given image file format and default JPEG compression quality using the default storage location.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithImageFileFormat:(SBSDKImageFileFormat)format;

    Swift

    init(imageFileFormat format: SBSDKImageFileFormat)

    Parameters

    format

    image file format.

    Return Value

    An instance of storage.

  • Initializes storage with JPEG image file format and given JPEG compression quality using the default storage location.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithJPEGFileFormatAndCompressionQuality:
        (NSInteger)jpegImageCompressionQuality;

    Swift

    init(jpegFileFormatAndCompressionQuality jpegImageCompressionQuality: Int)

    Parameters

    jpegImageCompressionQuality

    JPEG compression quality.

    Return Value

    An instance of storage.

  • Initializes storage with given image file format and default JPEG compression quality.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithImageFileFormat:(SBSDKImageFileFormat)format
                       location:(nullable SBSDKStorageLocation *)location;

    Swift

    init(imageFileFormat format: SBSDKImageFileFormat, location: SBSDKStorageLocation?)

    Parameters

    format

    image file format.

    location

    The storage location where image files are saved to. If nil, the default location is chosen.

    Return Value

    An instance of storage.

  • Initializes storage with JPEG image file format and given JPEG compression quality.

    Declaration

    Objective-C

    - (nonnull instancetype)
        initWithJPEGFileFormatAndCompressionQuality:
            (NSInteger)jpegImageCompressionQuality
                                           location:
                                               (nullable SBSDKStorageLocation *)
                                                   location;

    Swift

    init(jpegFileFormatAndCompressionQuality jpegImageCompressionQuality: Int, location: SBSDKStorageLocation?)

    Parameters

    jpegImageCompressionQuality

    JPEG compression quality.

    location

    The storage location where image files are saved to. If nil, the default location is chosen.

    Return Value

    An instance of storage.

  • The default instance of this class. *

    Declaration

    Objective-C

    + (nonnull instancetype)defaultStorage;

    Swift

    class func `default`() -> Self
  • Set default storage. If not used, default storage will be created with default parameters.

    Declaration

    Objective-C

    + (void)setDefaultStorage:(nonnull SBSDKUIPageFileStorage *)defaultStorage;

    Swift

    class func setDefault(_ defaultStorage: SBSDKUIPageFileStorage)
  • If file format is set to JPEG, this property holds the compression quality of the stored images. Values must be between 0 (high compression, small filesize, bad quality) and 100 (no compression, huge filesize, good image quality). Read-only. Defaults to 80.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSInteger writingJpegImageCompressionQuality;

    Swift

    var writingJpegImageCompressionQuality: Int { get }
  • File format of the stored images. Read-only. Defaults to JPEG.

    Declaration

    Objective-C

    @property (readonly, nonatomic) SBSDKImageFileFormat writingImageFileFormat;

    Swift

    var writingImageFileFormat: SBSDKImageFileFormat { get }
  • Adds an original image to the receiver.

    Declaration

    Objective-C

    - (nullable NSUUID *)addImage:(nonnull UIImage *)image;

    Swift

    func add(_ image: UIImage) -> UUID?

    Parameters

    image

    The UIImage instance to manage.

    Return Value

    The uuid of the added image that can be used to reference the image.

  • Replaces or sets an image with given page file ID and type. Use this function to update the document image.

    Caution: Setting/replacing the original image is not allowed and will result in an error!

    Declaration

    Objective-C

    - (BOOL)setImage:(nonnull UIImage *)image
        forExistingPageFileID:(nonnull NSUUID *)pageFileID
                 pageFileType:(SBSDKUIPageFileType)type
                        error:(NSError *_Nullable *_Nullable)error;

    Swift

    func setImage(_ image: UIImage, forExistingPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) throws

    Parameters

    image

    The new image to store.

    pageFileID

    The existing ID of the original image in the receiver. Returns an error if the ID does not exist in the receiver.

    type

    The type of the image to replace/set. Must not be ‘SBSDKUIPageFileTypeOriginal’.

    error

    An error pointer containing the error (if any) after the call.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Returns the URL of the full resolution image with given page file ID of given type.

    Declaration

    Objective-C

    - (nullable NSURL *)imageURLWithPageFileID:(nonnull NSUUID *)pageFileID
                                  pageFileType:(SBSDKUIPageFileType)type;

    Swift

    func imageURL(withPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) -> URL?

    Parameters

    pageFileID

    The page file ID of the requested image.

    type

    The type of the image.

    Return Value

    A URL pointing to the image file. Or nil if the image was not found.

  • Returns the full resolution image with given page file ID of given type.

    Declaration

    Objective-C

    - (nullable UIImage *)imageWithPageFileID:(nonnull NSUUID *)pageFileID
                                 pageFileType:(SBSDKUIPageFileType)type;

    Swift

    func image(withPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) -> UIImage?

    Parameters

    pageFileID

    The page file ID of the requested image.

    type

    The type of the image.

    Return Value

    An UIImage or nil if the image was not found.

  • Returns the URL of the preview resolution image with given page file ID of given type.

    Declaration

    Objective-C

    - (nullable NSURL *)previewImageURLWithPageFileID:(nonnull NSUUID *)pageFileID
                                         pageFileType:(SBSDKUIPageFileType)type;

    Swift

    func previewImageURL(withPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) -> URL?

    Parameters

    pageFileID

    The page file ID of the requested image.

    type

    The type of the image.

    Return Value

    A URL pointing to the image file. Or nil if the image was not found.

  • Returns the preview resolution image with given page file ID of given type.

    Declaration

    Objective-C

    - (nullable UIImage *)previewImageWithPageFileID:(nonnull NSUUID *)pageFileID
                                        pageFileType:(SBSDKUIPageFileType)type;

    Swift

    func previewImage(withPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) -> UIImage?

    Parameters

    pageFileID

    The page file ID of the requested image.

    type

    The type of the image.

    Return Value

    An UIImage or nil if the image was not found.

  • Removes stored images of given type with the given page file ID.

    Declaration

    Objective-C

    - (BOOL)removeImageForExistingPageFileID:(nonnull NSUUID *)pageFileID
                                pageFileType:(SBSDKUIPageFileType)type;

    Swift

    func removeImage(forExistingPageFileID pageFileID: UUID, pageFileType type: SBSDKUIPageFileType) -> Bool

    Parameters

    pageFileID

    The page file ID which should be removed from the receiver.

    type

    The type of image to be removed. Images of type ‘SBSDKUIPageFileTypeOriginal’ cannot be removed.

    Return Value

    YES, if the operation successful, NO otherwise.

  • Removes stored images of all types with the given page file ID.

    Declaration

    Objective-C

    - (void)removePageFileID:(nonnull NSUUID *)pageFileID;

    Swift

    func removePageFileID(_ pageFileID: UUID)

    Parameters

    pageFileID

    The page file ID which should be removed from the receiver.

  • Removes all stored images of all types except those from the exception list.

    Declaration

    Objective-C

    - (void)removeAllExceptPageFileIDs:(nonnull NSArray<NSUUID *> *)pageFileIDs;

    Swift

    func removeAllExceptPageFileIDs(_ pageFileIDs: [UUID])

    Parameters

    pageFileIDs

    The page file IDs of the images which should not be removed.

  • Clears the receiver. Removes all stored images files from disk.

    Declaration

    Objective-C

    - (void)removeAll;

    Swift

    func removeAll()
  • Returns all available IDs in storage

    Declaration

    Objective-C

    - (nonnull NSArray<NSUUID *> *)allPageFileIDs;

    Swift

    func allPageFileIDs() -> [UUID]