Authored by Klaas Pieter Annema

Scratch that, this won't work on UIButton

@@ -15,14 +15,6 @@ @@ -15,14 +15,6 @@
15 @interface UIButton (WebCache) 15 @interface UIButton (WebCache)
16 16
17 /** 17 /**
18 - * Get the current image URL.  
19 - *  
20 - * Note that because of the limitations of categories this property can get out of sync  
21 - * if you use setImage: directly.  
22 - */  
23 -- (NSURL *)currentImageURL;  
24 -  
25 -/**  
26 * Set the imageView `image` with an `url`. 18 * Set the imageView `image` with an `url`.
27 * 19 *
28 * The downloand is asynchronous and cached. 20 * The downloand is asynchronous and cached.
@@ -9,16 +9,10 @@ @@ -9,16 +9,10 @@
9 #import "UIButton+WebCache.h" 9 #import "UIButton+WebCache.h"
10 #import "objc/runtime.h" 10 #import "objc/runtime.h"
11 11
12 -static char imageURLKey;  
13 static char operationKey; 12 static char operationKey;
14 13
15 @implementation UIButton (WebCache) 14 @implementation UIButton (WebCache)
16 15
17 -- (NSURL *)currentImageURL;  
18 -{  
19 - return objc_getAssociatedObject(self, &imageURLKey);  
20 -}  
21 -  
22 - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state 16 - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state
23 { 17 {
24 [self setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; 18 [self setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
@@ -43,7 +37,6 @@ static char operationKey; @@ -43,7 +37,6 @@ static char operationKey;
43 - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { 37 - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
44 [self cancelCurrentImageLoad]; 38 [self cancelCurrentImageLoad];
45 39
46 - objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);  
47 [self setImage:placeholder forState:state]; 40 [self setImage:placeholder forState:state];
48 41
49 if (url) { 42 if (url) {