UIView(WebCacheOperation)

@interface UIView (WebCacheOperation)

These methods are used to support canceling for UIView image loading, it’s designed to be used internal but not external. All the stored operations are weak, so it will be dealloced after image loading finished. If you need to store operations, use your own class to keep a strong reference for them.

  • Get the image load operation for key

    Declaration

    Objective-C

    - (nullable id<SDWebImageOperation>)sd_imageLoadOperationForKey:
        (nullable NSString *)key;

    Swift

    func sd_imageLoadOperation(forKey key: String?) -> SDWebImageOperation?

    Parameters

    key

    key for identifying the operations

    Return Value

    the image load operation

  • Set the image load operation (storage in a UIView based weak map table)

    Declaration

    Objective-C

    - (void)sd_setImageLoadOperation:(nullable id<SDWebImageOperation>)operation
                              forKey:(nullable NSString *)key;

    Swift

    func sd_setImageLoad(_ operation: SDWebImageOperation?, forKey key: String?)

    Parameters

    operation

    the operation

    key

    key for storing the operation

  • Cancel all operations for the current UIView and key

    Declaration

    Objective-C

    - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key;

    Swift

    func sd_cancelImageLoadOperation(withKey key: String?)

    Parameters

    key

    key for identifying the operations

  • Just remove the operations corresponding to the current UIView and key without cancelling them

    Declaration

    Objective-C

    - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key;

    Swift

    func sd_removeImageLoadOperation(withKey key: String?)

    Parameters

    key

    key for identifying the operations