Procházet zdrojové kódy

Update the comments and associated key

DreamPiggy před 2 roky
rodič
revize
c614dffdfd

+ 1 - 1
SDWebImage/Core/UIButton+WebCache.h

@@ -21,7 +21,7 @@
 
 /**
  * Get the current image URL.
- * This simply translate to `[self sd_imageURLForState:self.state]` from v5.17.0
+ * This simply translate to `[self sd_imageURLForState:self.state]` from v5.18.0
  */
 @property (nonatomic, strong, readonly, nullable) NSURL *sd_currentImageURL;
 

+ 3 - 3
SDWebImage/Core/UIView+WebCache.h

@@ -32,7 +32,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
  *
  * @note You can use method `UIView+WebCacheOperation` to investigate different queries' operation.
  * @note For the history version compatible, when current UIView has property exactly called `image`, the operation key will use `NSStringFromClass(self.class)`. Include `UIImageView.image/NSImageView.image/NSButton.image` (without `UIButton`)
- * @warning This property should be only used for single state view, like `UIImageView` without highlighted state. For stateful view like `UIBUtton` (one view can have multiple images loading), check their header to call correct API, like `UIButton sd_imageURLForState:`
+ * @warning This property should be only used for single state view, like `UIImageView` without highlighted state. For stateful view like `UIBUtton` (one view can have multiple images loading), check their header to call correct API, like `-[UIButton sd_imageOperationKeyForState:]`
  */
 @property (nonatomic, strong, readonly, nullable) NSString *sd_latestOperationKey;
 
@@ -40,7 +40,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
 
 /**
  * Get the current image URL.
- * This simply translate to `[self sd_imageLoadStateForKey:self.sd_latestOperationKey].url` from v5.17.0
+ * This simply translate to `[self sd_imageLoadStateForKey:self.sd_latestOperationKey].url` from v5.18.0
  *
  * @note Note that because of the limitations of categories this property can get out of sync if you use setImage: directly.
  * @warning This property should be only used for single state view, like `UIImageView` without highlighted state. For stateful view like `UIBUtton` (one view can have multiple images loading), use `sd_imageLoadStateForKey:` instead. See `UIView+WebCacheState.h` for more information.
@@ -92,7 +92,7 @@ typedef void(^SDSetImageBlock)(UIImage * _Nullable image, NSData * _Nullable ima
 
 /**
  * Cancel the current image load
- * This simply translate to `[self sd_cancelImageLoadOperationWithKey:self.sd_latestOperationKey]` from v5.17.0
+ * This simply translate to `[self sd_cancelImageLoadOperationWithKey:self.sd_latestOperationKey]` from v5.18.0
  * 
  * @warning This method should be only used for single state view, like `UIImageView` without highlighted state. For stateful view like `UIBUtton` (one view can have multiple images loading), use `sd_cancelImageLoadOperationWithKey:` instead. See `UIView+WebCacheOperation.h` for more information.
  */

+ 2 - 3
SDWebImage/Core/UIView+WebCacheState.m

@@ -9,7 +9,6 @@
 #import "UIView+WebCacheState.h"
 #import "objc/runtime.h"
 
-static char loadStateKey;
 typedef NSMutableDictionary<NSString *, SDWebImageLoadState *> SDStatesDictionary;
 
 @implementation SDWebImageLoadState
@@ -19,10 +18,10 @@ typedef NSMutableDictionary<NSString *, SDWebImageLoadState *> SDStatesDictionar
 @implementation UIView (WebCacheState)
 
 - (SDStatesDictionary *)sd_imageLoadStateDictionary {
-    SDStatesDictionary *states = objc_getAssociatedObject(self, &loadStateKey);
+    SDStatesDictionary *states = objc_getAssociatedObject(self, @selector(sd_imageLoadStateDictionary));
     if (!states) {
         states = [NSMutableDictionary dictionary];
-        objc_setAssociatedObject(self, &loadStateKey, states, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
+        objc_setAssociatedObject(self, @selector(sd_imageLoadStateDictionary), states, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
     }
     return states;
 }