SBSDKIndexedImageStorage

@interface SBSDKIndexedImageStorage : NSObject <SBSDKImageStoring>

A simple thread-safe multiple-reader-single-writer index based disk image cache class. Manages images in an array-like fashion.

  • The number of stored images.

    Declaration

    Objective-C

    @property (readonly, nonatomic) NSUInteger imageCount;

    Swift

    var imageCount: UInt { get }
  • Array of all stored images URLs.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull) NSArray<NSURL *> *imageURLs;

    Swift

    var imageURLs: [URL] { get }
  • The JPEG compression if JPEG file format is used. Range: 0.0 - 1.0.

    Declaration

    Objective-C

    @property (assign, readwrite, nonatomic) CGFloat jpegCompressionQuality;

    Swift

    var jpegCompressionQuality: CGFloat { get set }
  • Image file format to be used to store the managed images.

    Declaration

    Objective-C

    @property (readonly, nonatomic) SBSDKImageFileFormat fileFormat;

    Swift

    var fileFormat: SBSDKImageFileFormat { get }
  • Initializes a new ‘SBSDKIndexedImageStorage’ at a temporary location (application caches folder). On deallocation the receiver will remove all its files from the file system.

    Declaration

    Objective-C

    + (nullable instancetype)temporaryStorage;

    Swift

    class func temporary() -> Self?

    Return Value

    A new ‘SBSDKIndexedImageStorage’ instance.

  • Initializes a new ‘SBSDKIndexedImageStorage’ at the given storage location.

    Declaration

    Objective-C

    - (nullable instancetype)initWithStorageLocation:
        (nullable SBSDKStorageLocation *)storageLocation;

    Swift

    init?(storageLocation: SBSDKStorageLocation?)

    Parameters

    storageLocation

    The storage location at which the new storage should reside.

    Return Value

    A new ‘SBSDKIndexedImageStorage’ instance at the given storage location.

  • Initializes a new ‘SBSDKIndexedImageStorage’ at the given storage location with given image file format.

    Declaration

    Objective-C

    - (nullable instancetype)
        initWithStorageLocation:(nullable SBSDKStorageLocation *)storageLocation
                     fileFormat:(SBSDKImageFileFormat)fileFormat;

    Swift

    init?(storageLocation: SBSDKStorageLocation?, fileFormat: SBSDKImageFileFormat)

    Parameters

    storageLocation

    The storage location at which the new storage should reside.

    fileFormat

    The file format that should be used to store the images.

    Return Value

    A new ‘SBSDKIndexedImageStorage’ instance at the given storage location.

  • Adds a new image to the receiver.

    Declaration

    Objective-C

    - (BOOL)addImage:(nonnull UIImage *)image;

    Swift

    func add(_ image: UIImage) -> Bool

    Parameters

    image

    The UIImage to be managed by the receiver.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Adds a new image to the receiver.

    Declaration

    Objective-C

    - (BOOL)addImageFromURL:(nonnull NSURL *)url;

    Swift

    func addImage(from url: URL) -> Bool

    Parameters

    url

    The URL the image is read from.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Returns the image at the given index.

    Declaration

    Objective-C

    - (nullable UIImage *)imageAtIndex:(NSUInteger)index;

    Swift

    func image(at index: UInt) -> UIImage?

    Parameters

    index

    The valid index at which the requested image is located at.

    Return Value

    The stored UIImage or nil, if there was no image at that index.

  • Returns the images file URL at the given index.

    Declaration

    Objective-C

    - (nullable NSURL *)imageURLAtIndex:(NSUInteger)index;

    Swift

    func imageURL(at index: UInt) -> URL?

    Parameters

    index

    The valid index at which the requested image is located at.

    Return Value

    The URL of the image file or nil, if there was no image at that index.

  • Inserts a new image into the receiver at the given index.

    Declaration

    Objective-C

    - (BOOL)insertImage:(nonnull UIImage *)image atIndex:(NSUInteger)index;

    Swift

    func insert(_ image: UIImage, at index: UInt) -> Bool

    Parameters

    image

    The UIImage to be managed by the receiver.

    index

    The valid index at which the new image should be inserted.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Moves the image at the source index to the destination index.

    Declaration

    Objective-C

    - (BOOL)moveImageFromIndex:(NSUInteger)sourceIndex
                       toIndex:(NSUInteger)destinationIndex;

    Swift

    func moveImage(from sourceIndex: UInt, to destinationIndex: UInt) -> Bool

    Parameters

    sourceIndex

    The valid current index of the image to be moved.

    destinationIndex

    The valid new index of the image to be moved.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Replaces the receivers image at index with the given image.

    Declaration

    Objective-C

    - (BOOL)replaceImageAtIndex:(NSInteger)index withImage:(nonnull UIImage *)image;

    Swift

    func replaceImage(at index: Int, with image: UIImage) -> Bool

    Parameters

    index

    The valid current index of the image to be replaced.

    image

    The new image that should be stored at the given index.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Replaces the receivers image at index with the image stored at the given URL.

    Declaration

    Objective-C

    - (BOOL)replaceImageAtIndex:(NSInteger)index
                 withImageAtURL:(nonnull NSURL *)url;

    Swift

    func replaceImage(at index: Int, withImageAt url: URL) -> Bool

    Parameters

    index

    The valid current index of the image to be replaced.

    url

    The URL of the new image that should be stored at the given index.

    Return Value

    YES, if the operation was successfull, NO otherwise.

  • Removes the image at the given index from the receiver as well as from the the file system.

    Declaration

    Objective-C

    - (void)removeImageAtIndex:(NSUInteger)index;

    Swift

    func removeImage(at index: UInt)

    Parameters

    index

    The valid index of the image to be removed.

  • Removes all stored images from the receiver as well as from the file system.

    Declaration

    Objective-C

    - (void)removeAllImages;

    Swift

    func removeAllImages()
  • Blocks the current thread until all enqueued writing operations have been finished.

    Declaration

    Objective-C

    - (void)waitUntilWritingCompleted;

    Swift

    func waitUntilWritingCompleted()