UIView+WebCacheOperation.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import "SDWebImageCompat.h"
  9. #import "SDWebImageOperation.h"
  10. /**
  11. These methods are used to support canceling for UIView image loading, it's designed to be used internal but not external.
  12. 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.
  13. */
  14. @interface UIView (WebCacheOperation)
  15. /**
  16. * Get the image load operation for key
  17. *
  18. * @param key key for identifying the operations
  19. * @return the image load operation
  20. */
  21. - (nullable id<SDWebImageOperation>)sd_imageLoadOperationForKey:(nullable NSString *)key;
  22. /**
  23. * Set the image load operation (storage in a UIView based weak map table)
  24. *
  25. * @param operation the operation
  26. * @param key key for storing the operation
  27. */
  28. - (void)sd_setImageLoadOperation:(nullable id<SDWebImageOperation>)operation forKey:(nullable NSString *)key;
  29. /**
  30. * Cancel all operations for the current UIView and key
  31. *
  32. * @param key key for identifying the operations
  33. */
  34. - (void)sd_cancelImageLoadOperationWithKey:(nullable NSString *)key;
  35. /**
  36. * Just remove the operations corresponding to the current UIView and key without cancelling them
  37. *
  38. * @param key key for identifying the operations
  39. */
  40. - (void)sd_removeImageLoadOperationWithKey:(nullable NSString *)key;
  41. @end