SDWebImageCacheSerializer

@protocol SDWebImageCacheSerializer <NSObject>

This is the protocol for cache serializer. We can use a block to specify the cache serializer. But Using protocol can make this extensible, and allow Swift user to use it easily instead of using @convention(block) to store a block into context options.

  • Provide the image data associated to the image and store to disk cache

    Declaration

    Objective-C

    - (nullable NSData *)cacheDataWithImage:(nonnull UIImage *)image
                               originalData:(nullable NSData *)data
                                   imageURL:(nullable NSURL *)imageURL;

    Swift

    func cacheData(with image: UIImage, originalData data: Data?, imageURL: URL?) -> Data?

    Parameters

    image

    The loaded image

    data

    The original loaded image data

    imageURL

    The image URL