SBSDKKeyedImageStorage

@interface SBSDKKeyedImageStorage : NSObject

A simple thread-safe multiple-reader-single-writer key-value fashioned disk image cache class. Manages images in a dictionary-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 (values).

    Declaration

    Objective-C

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

    Swift

    var imageURLs: [URL] { get }
  • Array of all stored keys.

    Declaration

    Objective-C

    @property (readonly, nonatomic, nonnull) NSArray<NSString *> *imageKeys;

    Swift

    var imageKeys: [String] { get }
  • Image file format to be used to store the managed images.

    Declaration

    Objective-C

    @property (readonly, nonatomic) SBSDKImageFileFormat fileFormat;

    Swift

    var fileFormat: SBSDKImageFileFormat { 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 }
  • Initializes a new ‘SBSDKKeyedImageStorage’ 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 ‘SBSDKKeyedImageStorage’ instance at the given storage location.

  • Initializes a new ‘SBSDKKeyedImageStorage’ 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 ‘SBSDKKeyedImageStorage’ instance at the given storage location.

  • Stores an image at the given key.

    Declaration

    Objective-C

    - (void)setImage:(nonnull UIImage *)image forKey:(nonnull NSString *)key;

    Swift

    func setImage(_ image: UIImage, forKey key: String)

    Parameters

    image

    The UIImage to be managed by the receiver.

    key

    The key at which to store the image.

  • Returns the image file URL for given key.

    Declaration

    Objective-C

    - (nullable NSURL *)imageURLForKey:(nonnull NSString *)key;

    Swift

    func imageURL(forKey key: String) -> URL?

    Parameters

    key

    The key at which the requested image was stored.

    Return Value

    A URL in the file system pointing to the image file or nil, if there was no image at that key. Caution: Do not perform any write operations at that URL!

  • Returns the image for given key.

    Declaration

    Objective-C

    - (nullable UIImage *)imageForKey:(nonnull NSString *)key;

    Swift

    func image(forKey key: String) -> UIImage?

    Parameters

    key

    The key at which the requested image was stored.

    Return Value

    The stored UIImage or nil, if there was no image at that key. Caution: Do not perform any write operations at that URL!

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

    Declaration

    Objective-C

    - (void)removeImageForKey:(nonnull NSString *)key;

    Swift

    func removeImage(forKey key: String)

    Parameters

    key

    The key for the image that should be removed.

  • Removes the images at keys from the receiver as well as from the file system, which keys prefix match the prefix string.

    Declaration

    Objective-C

    - (void)removeImagesForKeysMatchingPrefix:(nonnull NSString *)prefix;

    Swift

    func removeImagesForKeys(matchingPrefix prefix: String)

    Parameters

    prefix

    The prefix of the keys for the images that should 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()