Fixed #775, made sure all the category methods that are public have the sd_ pref…
…ix (deprecated the old ones) -there were a few exceptions where I just renamed the methods since they were added in this method
Showing
14 changed files
with
128 additions
and
63 deletions
@@ -20,7 +20,7 @@ | @@ -20,7 +20,7 @@ | ||
20 | * Note that because of the limitations of categories this property can get out of sync | 20 | * Note that because of the limitations of categories this property can get out of sync |
21 | * if you use sd_setImage: directly. | 21 | * if you use sd_setImage: directly. |
22 | */ | 22 | */ |
23 | -- (NSURL *)imageURL; | 23 | +- (NSURL *)sd_imageURL; |
24 | 24 | ||
25 | /** | 25 | /** |
26 | * Set the imageView `image` with an `url`. | 26 | * Set the imageView `image` with an `url`. |
@@ -102,13 +102,15 @@ | @@ -102,13 +102,15 @@ | ||
102 | /** | 102 | /** |
103 | * Cancel the current download | 103 | * Cancel the current download |
104 | */ | 104 | */ |
105 | -- (void)cancelCurrentImageLoad; | 105 | +- (void)sd_cancelCurrentImageLoad; |
106 | 106 | ||
107 | @end | 107 | @end |
108 | 108 | ||
109 | 109 | ||
110 | @interface MKAnnotationView (WebCacheDeprecated) | 110 | @interface MKAnnotationView (WebCacheDeprecated) |
111 | 111 | ||
112 | +- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); | ||
113 | + | ||
112 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); | 114 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); |
113 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); | 115 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); |
114 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`"); | 116 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`"); |
@@ -117,4 +119,6 @@ | @@ -117,4 +119,6 @@ | ||
117 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); | 119 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`"); |
118 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); | 120 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); |
119 | 121 | ||
122 | +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`"); | ||
123 | + | ||
120 | @end | 124 | @end |
@@ -14,7 +14,7 @@ static char imageURLKey; | @@ -14,7 +14,7 @@ static char imageURLKey; | ||
14 | 14 | ||
15 | @implementation MKAnnotationView (WebCache) | 15 | @implementation MKAnnotationView (WebCache) |
16 | 16 | ||
17 | -- (NSURL *)imageURL { | 17 | +- (NSURL *)sd_imageURL { |
18 | return objc_getAssociatedObject(self, &imageURLKey); | 18 | return objc_getAssociatedObject(self, &imageURLKey); |
19 | } | 19 | } |
20 | 20 | ||
@@ -59,7 +59,7 @@ static char imageURLKey; | @@ -59,7 +59,7 @@ static char imageURLKey; | ||
59 | } | 59 | } |
60 | }); | 60 | }); |
61 | }]; | 61 | }]; |
62 | - [self setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; | 62 | + [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; |
63 | } else { | 63 | } else { |
64 | dispatch_main_async_safe(^{ | 64 | dispatch_main_async_safe(^{ |
65 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 65 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
@@ -70,8 +70,8 @@ static char imageURLKey; | @@ -70,8 +70,8 @@ static char imageURLKey; | ||
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | -- (void)cancelCurrentImageLoad { | ||
74 | - [self cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; | 73 | +- (void)sd_cancelCurrentImageLoad { |
74 | + [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; | ||
75 | } | 75 | } |
76 | 76 | ||
77 | @end | 77 | @end |
@@ -79,6 +79,10 @@ static char imageURLKey; | @@ -79,6 +79,10 @@ static char imageURLKey; | ||
79 | 79 | ||
80 | @implementation MKAnnotationView (WebCacheDeprecated) | 80 | @implementation MKAnnotationView (WebCacheDeprecated) |
81 | 81 | ||
82 | +- (NSURL *)imageURL { | ||
83 | + return [self sd_imageURL]; | ||
84 | +} | ||
85 | + | ||
82 | - (void)setImageWithURL:(NSURL *)url { | 86 | - (void)setImageWithURL:(NSURL *)url { |
83 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; | 87 | [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; |
84 | } | 88 | } |
@@ -115,4 +119,8 @@ static char imageURLKey; | @@ -115,4 +119,8 @@ static char imageURLKey; | ||
115 | }]; | 119 | }]; |
116 | } | 120 | } |
117 | 121 | ||
122 | +- (void)cancelCurrentImageLoad { | ||
123 | + [self sd_cancelCurrentImageLoad]; | ||
124 | +} | ||
125 | + | ||
118 | @end | 126 | @end |
@@ -14,6 +14,13 @@ | @@ -14,6 +14,13 @@ | ||
14 | * | 14 | * |
15 | * @return the content type as string (i.e. image/jpeg, image/gif) | 15 | * @return the content type as string (i.e. image/jpeg, image/gif) |
16 | */ | 16 | */ |
17 | -+ (NSString *)contentTypeForImageData:(NSData *)data; | 17 | ++ (NSString *)sd_contentTypeForImageData:(NSData *)data; |
18 | + | ||
19 | +@end | ||
20 | + | ||
21 | + | ||
22 | +@interface NSData (ImageContentTypeDeprecated) | ||
23 | + | ||
24 | ++ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`"); | ||
18 | 25 | ||
19 | @end | 26 | @end |
@@ -8,7 +8,7 @@ | @@ -8,7 +8,7 @@ | ||
8 | 8 | ||
9 | @implementation NSData (ImageContentType) | 9 | @implementation NSData (ImageContentType) |
10 | 10 | ||
11 | -+ (NSString *)contentTypeForImageData:(NSData *)data { | 11 | ++ (NSString *)sd_contentTypeForImageData:(NSData *)data { |
12 | uint8_t c; | 12 | uint8_t c; |
13 | [data getBytes:&c length:1]; | 13 | [data getBytes:&c length:1]; |
14 | switch (c) { | 14 | switch (c) { |
@@ -38,3 +38,12 @@ | @@ -38,3 +38,12 @@ | ||
38 | } | 38 | } |
39 | 39 | ||
40 | @end | 40 | @end |
41 | + | ||
42 | + | ||
43 | +@implementation NSData (ImageContentTypeDeprecated) | ||
44 | + | ||
45 | ++ (NSString *)contentTypeForImageData:(NSData *)data { | ||
46 | + return [self sd_contentTypeForImageData:data]; | ||
47 | +} | ||
48 | + | ||
49 | +@end |
@@ -17,14 +17,14 @@ | @@ -17,14 +17,14 @@ | ||
17 | /** | 17 | /** |
18 | * Get the current image URL. | 18 | * Get the current image URL. |
19 | */ | 19 | */ |
20 | -- (NSURL *)currentImageURL; | 20 | +- (NSURL *)sd_currentImageURL; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Get the image URL for a control state. | 23 | * Get the image URL for a control state. |
24 | * | 24 | * |
25 | * @param state Which state you want to know the URL for. The values are described in UIControlState. | 25 | * @param state Which state you want to know the URL for. The values are described in UIControlState. |
26 | */ | 26 | */ |
27 | -- (NSURL *)imageURLForState:(UIControlState)state; | 27 | +- (NSURL *)sd_imageURLForState:(UIControlState)state; |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Set the imageView `image` with an `url`. | 30 | * Set the imageView `image` with an `url`. |
@@ -192,18 +192,21 @@ | @@ -192,18 +192,21 @@ | ||
192 | /** | 192 | /** |
193 | * Cancel the current image download | 193 | * Cancel the current image download |
194 | */ | 194 | */ |
195 | -- (void)cancelImageLoadForState:(UIControlState)state; | 195 | +- (void)sd_cancelImageLoadForState:(UIControlState)state; |
196 | 196 | ||
197 | /** | 197 | /** |
198 | * Cancel the current backgroundImage download | 198 | * Cancel the current backgroundImage download |
199 | */ | 199 | */ |
200 | -- (void)cancelBackgroundImageLoadForState:(UIControlState)state; | 200 | +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state; |
201 | 201 | ||
202 | @end | 202 | @end |
203 | 203 | ||
204 | 204 | ||
205 | @interface UIButton (WebCacheDeprecated) | 205 | @interface UIButton (WebCacheDeprecated) |
206 | 206 | ||
207 | +- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`"); | ||
208 | +- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`"); | ||
209 | + | ||
207 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); | 210 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`"); |
208 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); | 211 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`"); |
209 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); | 212 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:options:`"); |
@@ -220,6 +223,7 @@ | @@ -220,6 +223,7 @@ | ||
220 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); | 223 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`"); |
221 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); | 224 | - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:options:completed:`"); |
222 | 225 | ||
223 | -- (void)cancelCurrentImageLoad __deprecated_msg("Use `cancelImageLoadForState:`"); | 226 | +- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`"); |
227 | +- (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`"); | ||
224 | 228 | ||
225 | @end | 229 | @end |
@@ -14,7 +14,7 @@ static char imageURLStorageKey; | @@ -14,7 +14,7 @@ static char imageURLStorageKey; | ||
14 | 14 | ||
15 | @implementation UIButton (WebCache) | 15 | @implementation UIButton (WebCache) |
16 | 16 | ||
17 | -- (NSURL *)currentImageURL { | 17 | +- (NSURL *)sd_currentImageURL { |
18 | NSURL *url = self.imageURLStorage[@(self.state)]; | 18 | NSURL *url = self.imageURLStorage[@(self.state)]; |
19 | 19 | ||
20 | if (!url) { | 20 | if (!url) { |
@@ -24,7 +24,7 @@ static char imageURLStorageKey; | @@ -24,7 +24,7 @@ static char imageURLStorageKey; | ||
24 | return url; | 24 | return url; |
25 | } | 25 | } |
26 | 26 | ||
27 | -- (NSURL *)imageURLForState:(UIControlState)state { | 27 | +- (NSURL *)sd_imageURLForState:(UIControlState)state { |
28 | return self.imageURLStorage[@(state)]; | 28 | return self.imageURLStorage[@(state)]; |
29 | } | 29 | } |
30 | 30 | ||
@@ -51,7 +51,7 @@ static char imageURLStorageKey; | @@ -51,7 +51,7 @@ static char imageURLStorageKey; | ||
51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { | 51 | - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { |
52 | 52 | ||
53 | [self setImage:placeholder forState:state]; | 53 | [self setImage:placeholder forState:state]; |
54 | - [self cancelImageLoadForState:state]; | 54 | + [self sd_cancelImageLoadForState:state]; |
55 | 55 | ||
56 | if (!url) { | 56 | if (!url) { |
57 | [self.imageURLStorage removeObjectForKey:@(state)]; | 57 | [self.imageURLStorage removeObjectForKey:@(state)]; |
@@ -82,7 +82,7 @@ static char imageURLStorageKey; | @@ -82,7 +82,7 @@ static char imageURLStorageKey; | ||
82 | } | 82 | } |
83 | }); | 83 | }); |
84 | }]; | 84 | }]; |
85 | - [self setImageLoadOperation:operation forState:state]; | 85 | + [self sd_setImageLoadOperation:operation forState:state]; |
86 | } | 86 | } |
87 | 87 | ||
88 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { | 88 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { |
@@ -106,7 +106,7 @@ static char imageURLStorageKey; | @@ -106,7 +106,7 @@ static char imageURLStorageKey; | ||
106 | } | 106 | } |
107 | 107 | ||
108 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { | 108 | - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { |
109 | - [self cancelImageLoadForState:state]; | 109 | + [self sd_cancelImageLoadForState:state]; |
110 | 110 | ||
111 | [self setBackgroundImage:placeholder forState:state]; | 111 | [self setBackgroundImage:placeholder forState:state]; |
112 | 112 | ||
@@ -125,7 +125,7 @@ static char imageURLStorageKey; | @@ -125,7 +125,7 @@ static char imageURLStorageKey; | ||
125 | } | 125 | } |
126 | }); | 126 | }); |
127 | }]; | 127 | }]; |
128 | - [self setBackgroundImageLoadOperation:operation forState:state]; | 128 | + [self sd_setBackgroundImageLoadOperation:operation forState:state]; |
129 | } else { | 129 | } else { |
130 | dispatch_main_async_safe(^{ | 130 | dispatch_main_async_safe(^{ |
131 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 131 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
@@ -136,20 +136,20 @@ static char imageURLStorageKey; | @@ -136,20 +136,20 @@ static char imageURLStorageKey; | ||
136 | } | 136 | } |
137 | } | 137 | } |
138 | 138 | ||
139 | -- (void)setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { | ||
140 | - [self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; | 139 | +- (void)sd_setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { |
140 | + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; | ||
141 | } | 141 | } |
142 | 142 | ||
143 | -- (void)cancelImageLoadForState:(UIControlState)state { | ||
144 | - [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; | 143 | +- (void)sd_cancelImageLoadForState:(UIControlState)state { |
144 | + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; | ||
145 | } | 145 | } |
146 | 146 | ||
147 | -- (void)setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { | ||
148 | - [self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; | 147 | +- (void)sd_setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { |
148 | + [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; | ||
149 | } | 149 | } |
150 | 150 | ||
151 | -- (void)cancelBackgroundImageLoadForState:(UIControlState)state { | ||
152 | - [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; | 151 | +- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state { |
152 | + [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; | ||
153 | } | 153 | } |
154 | 154 | ||
155 | - (NSMutableDictionary *)imageURLStorage { | 155 | - (NSMutableDictionary *)imageURLStorage { |
@@ -168,6 +168,14 @@ static char imageURLStorageKey; | @@ -168,6 +168,14 @@ static char imageURLStorageKey; | ||
168 | 168 | ||
169 | @implementation UIButton (WebCacheDeprecated) | 169 | @implementation UIButton (WebCacheDeprecated) |
170 | 170 | ||
171 | +- (NSURL *)currentImageURL { | ||
172 | + return [self sd_currentImageURL]; | ||
173 | +} | ||
174 | + | ||
175 | +- (NSURL *)imageURLForState:(UIControlState)state { | ||
176 | + return [self sd_imageURLForState:state]; | ||
177 | +} | ||
178 | + | ||
171 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { | 179 | - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state { |
172 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; | 180 | [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; |
173 | } | 181 | } |
@@ -242,7 +250,11 @@ static char imageURLStorageKey; | @@ -242,7 +250,11 @@ static char imageURLStorageKey; | ||
242 | 250 | ||
243 | - (void)cancelCurrentImageLoad { | 251 | - (void)cancelCurrentImageLoad { |
244 | // in a backwards compatible manner, cancel for current state | 252 | // in a backwards compatible manner, cancel for current state |
245 | - [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(self.state)]]; | 253 | + [self sd_cancelImageLoadForState:self.state]; |
254 | +} | ||
255 | + | ||
256 | +- (void)cancelBackgroundImageLoadForState:(UIControlState)state { | ||
257 | + [self sd_cancelBackgroundImageLoadForState:state]; | ||
246 | } | 258 | } |
247 | 259 | ||
248 | @end | 260 | @end |
@@ -33,7 +33,7 @@ | @@ -33,7 +33,7 @@ | ||
33 | for (size_t i = 0; i < count; i++) { | 33 | for (size_t i = 0; i < count; i++) { |
34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); | 34 | CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); |
35 | 35 | ||
36 | - duration += [self frameDurationAtIndex:i source:source]; | 36 | + duration += [self sd_frameDurationAtIndex:i source:source]; |
37 | 37 | ||
38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; | 38 | [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]]; |
39 | 39 | ||
@@ -52,7 +52,7 @@ | @@ -52,7 +52,7 @@ | ||
52 | return animatedImage; | 52 | return animatedImage; |
53 | } | 53 | } |
54 | 54 | ||
55 | -+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { | 55 | ++ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { |
56 | float frameDuration = 0.1f; | 56 | float frameDuration = 0.1f; |
57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); | 57 | CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); |
58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; | 58 | NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; |
@@ -19,7 +19,7 @@ | @@ -19,7 +19,7 @@ | ||
19 | 19 | ||
20 | + (UIImage *)sd_imageWithData:(NSData *)data { | 20 | + (UIImage *)sd_imageWithData:(NSData *)data { |
21 | UIImage *image; | 21 | UIImage *image; |
22 | - NSString *imageContentType = [NSData contentTypeForImageData:data]; | 22 | + NSString *imageContentType = [NSData sd_contentTypeForImageData:data]; |
23 | if ([imageContentType isEqualToString:@"image/gif"]) { | 23 | if ([imageContentType isEqualToString:@"image/gif"]) { |
24 | image = [UIImage sd_animatedGIFWithData:data]; | 24 | image = [UIImage sd_animatedGIFWithData:data]; |
25 | } | 25 | } |
@@ -82,7 +82,7 @@ | @@ -82,7 +82,7 @@ | ||
82 | /** | 82 | /** |
83 | * Cancel the current download | 83 | * Cancel the current download |
84 | */ | 84 | */ |
85 | -- (void)cancelCurrentHighlightedImageLoad; | 85 | +- (void)sd_cancelCurrentHighlightedImageLoad; |
86 | 86 | ||
87 | @end | 87 | @end |
88 | 88 | ||
@@ -95,4 +95,6 @@ | @@ -95,4 +95,6 @@ | ||
95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); | 95 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`"); |
96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); | 96 | - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`"); |
97 | 97 | ||
98 | +- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`"); | ||
99 | + | ||
98 | @end | 100 | @end |
@@ -30,7 +30,7 @@ | @@ -30,7 +30,7 @@ | ||
30 | } | 30 | } |
31 | 31 | ||
32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { | 32 | - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { |
33 | - [self cancelCurrentHighlightedImageLoad]; | 33 | + [self sd_cancelCurrentHighlightedImageLoad]; |
34 | 34 | ||
35 | if (url) { | 35 | if (url) { |
36 | __weak UIImageView *wself = self; | 36 | __weak UIImageView *wself = self; |
@@ -48,7 +48,7 @@ | @@ -48,7 +48,7 @@ | ||
48 | } | 48 | } |
49 | }); | 49 | }); |
50 | }]; | 50 | }]; |
51 | - [self setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; | 51 | + [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; |
52 | } else { | 52 | } else { |
53 | dispatch_main_async_safe(^{ | 53 | dispatch_main_async_safe(^{ |
54 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 54 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
@@ -59,8 +59,8 @@ | @@ -59,8 +59,8 @@ | ||
59 | } | 59 | } |
60 | } | 60 | } |
61 | 61 | ||
62 | -- (void)cancelCurrentHighlightedImageLoad { | ||
63 | - [self cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; | 62 | +- (void)sd_cancelCurrentHighlightedImageLoad { |
63 | + [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; | ||
64 | } | 64 | } |
65 | 65 | ||
66 | @end | 66 | @end |
@@ -100,4 +100,8 @@ | @@ -100,4 +100,8 @@ | ||
100 | }]; | 100 | }]; |
101 | } | 101 | } |
102 | 102 | ||
103 | +- (void)cancelCurrentHighlightedImageLoad { | ||
104 | + [self sd_cancelCurrentHighlightedImageLoad]; | ||
105 | +} | ||
106 | + | ||
103 | @end | 107 | @end |
@@ -50,7 +50,7 @@ | @@ -50,7 +50,7 @@ | ||
50 | * Note that because of the limitations of categories this property can get out of sync | 50 | * Note that because of the limitations of categories this property can get out of sync |
51 | * if you use sd_setImage: directly. | 51 | * if you use sd_setImage: directly. |
52 | */ | 52 | */ |
53 | -- (NSURL *)imageURL; | 53 | +- (NSURL *)sd_imageURL; |
54 | 54 | ||
55 | /** | 55 | /** |
56 | * Set the imageView `image` with an `url`. | 56 | * Set the imageView `image` with an `url`. |
@@ -148,22 +148,24 @@ | @@ -148,22 +148,24 @@ | ||
148 | /** | 148 | /** |
149 | * Download an array of images and starts them in an animation loop | 149 | * Download an array of images and starts them in an animation loop |
150 | * | 150 | * |
151 | - *@param arrayOfURLs An array of NSURL | 151 | + * @param arrayOfURLs An array of NSURL |
152 | */ | 152 | */ |
153 | -- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; | 153 | +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; |
154 | 154 | ||
155 | /** | 155 | /** |
156 | * Cancel the current download | 156 | * Cancel the current download |
157 | */ | 157 | */ |
158 | -- (void)cancelCurrentImageLoad; | 158 | +- (void)sd_cancelCurrentImageLoad; |
159 | 159 | ||
160 | -- (void)cancelCurrentAnimationImagesLoad; | 160 | +- (void)sd_cancelCurrentAnimationImagesLoad; |
161 | 161 | ||
162 | @end | 162 | @end |
163 | 163 | ||
164 | 164 | ||
165 | @interface UIImageView (WebCacheDeprecated) | 165 | @interface UIImageView (WebCacheDeprecated) |
166 | 166 | ||
167 | +- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`"); | ||
168 | + | ||
167 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); | 169 | - (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); |
168 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); | 170 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`"); |
169 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); | 171 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`"); |
@@ -173,6 +175,10 @@ | @@ -173,6 +175,10 @@ | ||
173 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); | 175 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`"); |
174 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); | 176 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:progress:completed:`"); |
175 | 177 | ||
176 | -- (void)cancelCurrentArrayLoad __deprecated_msg("Use `cancelCurrentAnimationImagesLoad`"); | 178 | +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`"); |
179 | + | ||
180 | +- (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`"); | ||
181 | + | ||
182 | +- (void)cancelCurrentImageLoad __deprecated_msg("Use `cancelCurrentImageLoad`"); | ||
177 | 183 | ||
178 | @end | 184 | @end |
@@ -39,7 +39,7 @@ static char imageURLKey; | @@ -39,7 +39,7 @@ static char imageURLKey; | ||
39 | } | 39 | } |
40 | 40 | ||
41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { | 41 | - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { |
42 | - [self cancelCurrentImageLoad]; | 42 | + [self sd_cancelCurrentImageLoad]; |
43 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | 43 | objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); |
44 | 44 | ||
45 | if (!(options & SDWebImageDelayPlaceholder)) { | 45 | if (!(options & SDWebImageDelayPlaceholder)) { |
@@ -66,7 +66,7 @@ static char imageURLKey; | @@ -66,7 +66,7 @@ static char imageURLKey; | ||
66 | } | 66 | } |
67 | }); | 67 | }); |
68 | }]; | 68 | }]; |
69 | - [self setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; | 69 | + [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; |
70 | } else { | 70 | } else { |
71 | dispatch_main_async_safe(^{ | 71 | dispatch_main_async_safe(^{ |
72 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; | 72 | NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; |
@@ -77,12 +77,12 @@ static char imageURLKey; | @@ -77,12 +77,12 @@ static char imageURLKey; | ||
77 | } | 77 | } |
78 | } | 78 | } |
79 | 79 | ||
80 | -- (NSURL *)imageURL { | 80 | +- (NSURL *)sd_imageURL { |
81 | return objc_getAssociatedObject(self, &imageURLKey); | 81 | return objc_getAssociatedObject(self, &imageURLKey); |
82 | } | 82 | } |
83 | 83 | ||
84 | -- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { | ||
85 | - [self cancelCurrentAnimationImagesLoad]; | 84 | +- (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { |
85 | + [self sd_cancelCurrentAnimationImagesLoad]; | ||
86 | __weak UIImageView *wself = self; | 86 | __weak UIImageView *wself = self; |
87 | 87 | ||
88 | NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; | 88 | NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; |
@@ -109,15 +109,15 @@ static char imageURLKey; | @@ -109,15 +109,15 @@ static char imageURLKey; | ||
109 | [operationsArray addObject:operation]; | 109 | [operationsArray addObject:operation]; |
110 | } | 110 | } |
111 | 111 | ||
112 | - [self setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; | 112 | + [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; |
113 | } | 113 | } |
114 | 114 | ||
115 | -- (void)cancelCurrentImageLoad { | ||
116 | - [self cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; | 115 | +- (void)sd_cancelCurrentImageLoad { |
116 | + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; | ||
117 | } | 117 | } |
118 | 118 | ||
119 | -- (void)cancelCurrentAnimationImagesLoad { | ||
120 | - [self cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; | 119 | +- (void)sd_cancelCurrentAnimationImagesLoad { |
120 | + [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; | ||
121 | } | 121 | } |
122 | 122 | ||
123 | @end | 123 | @end |
@@ -125,6 +125,10 @@ static char imageURLKey; | @@ -125,6 +125,10 @@ static char imageURLKey; | ||
125 | 125 | ||
126 | @implementation UIImageView (WebCacheDeprecated) | 126 | @implementation UIImageView (WebCacheDeprecated) |
127 | 127 | ||
128 | +- (NSURL *)imageURL { | ||
129 | + return [self sd_imageURL]; | ||
130 | +} | ||
131 | + | ||
128 | - (void)setImageWithURL:(NSURL *)url { | 132 | - (void)setImageWithURL:(NSURL *)url { |
129 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; | 133 | [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; |
130 | } | 134 | } |
@@ -151,7 +155,6 @@ static char imageURLKey; | @@ -151,7 +155,6 @@ static char imageURLKey; | ||
151 | completedBlock(image, error, cacheType); | 155 | completedBlock(image, error, cacheType); |
152 | } | 156 | } |
153 | }]; | 157 | }]; |
154 | - | ||
155 | } | 158 | } |
156 | 159 | ||
157 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { | 160 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { |
@@ -160,7 +163,6 @@ static char imageURLKey; | @@ -160,7 +163,6 @@ static char imageURLKey; | ||
160 | completedBlock(image, error, cacheType); | 163 | completedBlock(image, error, cacheType); |
161 | } | 164 | } |
162 | }]; | 165 | }]; |
163 | - | ||
164 | } | 166 | } |
165 | 167 | ||
166 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { | 168 | - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { |
@@ -169,11 +171,18 @@ static char imageURLKey; | @@ -169,11 +171,18 @@ static char imageURLKey; | ||
169 | completedBlock(image, error, cacheType); | 171 | completedBlock(image, error, cacheType); |
170 | } | 172 | } |
171 | }]; | 173 | }]; |
172 | - | ||
173 | } | 174 | } |
174 | 175 | ||
175 | - (void)cancelCurrentArrayLoad { | 176 | - (void)cancelCurrentArrayLoad { |
176 | - [self cancelCurrentAnimationImagesLoad]; | 177 | + [self sd_cancelCurrentAnimationImagesLoad]; |
178 | +} | ||
179 | + | ||
180 | +- (void)cancelCurrentImageLoad { | ||
181 | + [self sd_cancelCurrentImageLoad]; | ||
182 | +} | ||
183 | + | ||
184 | +- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { | ||
185 | + [self sd_setAnimationImagesWithURLs:arrayOfURLs]; | ||
177 | } | 186 | } |
178 | 187 | ||
179 | @end | 188 | @end |
@@ -17,20 +17,20 @@ | @@ -17,20 +17,20 @@ | ||
17 | * @param operation the operation | 17 | * @param operation the operation |
18 | * @param key key for storing the operation | 18 | * @param key key for storing the operation |
19 | */ | 19 | */ |
20 | -- (void)setImageLoadOperation:(id)operation forKey:(NSString *)key; | 20 | +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key; |
21 | 21 | ||
22 | /** | 22 | /** |
23 | * Cancel all operations for the current UIView and key | 23 | * Cancel all operations for the current UIView and key |
24 | * | 24 | * |
25 | * @param key key for identifying the operations | 25 | * @param key key for identifying the operations |
26 | */ | 26 | */ |
27 | -- (void)cancelImageLoadOperationWithKey:(NSString *)key; | 27 | +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key; |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Just remove the operations corresponding to the current UIView and key without cancelling them | 30 | * Just remove the operations corresponding to the current UIView and key without cancelling them |
31 | * | 31 | * |
32 | * @param key key for identifying the operations | 32 | * @param key key for identifying the operations |
33 | */ | 33 | */ |
34 | -- (void)removeImageLoadOperationWithKey:(NSString *)key; | 34 | +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key; |
35 | 35 | ||
36 | @end | 36 | @end |
@@ -23,13 +23,13 @@ static char loadOperationKey; | @@ -23,13 +23,13 @@ static char loadOperationKey; | ||
23 | return operations; | 23 | return operations; |
24 | } | 24 | } |
25 | 25 | ||
26 | -- (void)setImageLoadOperation:(id)operation forKey:(NSString *)key { | ||
27 | - [self cancelImageLoadOperationWithKey:key]; | 26 | +- (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key { |
27 | + [self sd_cancelImageLoadOperationWithKey:key]; | ||
28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; | 28 | NSMutableDictionary *operationDictionary = [self operationDictionary]; |
29 | [operationDictionary setObject:operation forKey:key]; | 29 | [operationDictionary setObject:operation forKey:key]; |
30 | } | 30 | } |
31 | 31 | ||
32 | -- (void)cancelImageLoadOperationWithKey:(NSString *)key { | 32 | +- (void)sd_cancelImageLoadOperationWithKey:(NSString *)key { |
33 | // Cancel in progress downloader from queue | 33 | // Cancel in progress downloader from queue |
34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; | 34 | NSMutableDictionary *operationDictionary = [self operationDictionary]; |
35 | id operations = [operationDictionary objectForKey:key]; | 35 | id operations = [operationDictionary objectForKey:key]; |
@@ -47,7 +47,7 @@ static char loadOperationKey; | @@ -47,7 +47,7 @@ static char loadOperationKey; | ||
47 | } | 47 | } |
48 | } | 48 | } |
49 | 49 | ||
50 | -- (void)removeImageLoadOperationWithKey:(NSString *)key { | 50 | +- (void)sd_removeImageLoadOperationWithKey:(NSString *)key { |
51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; | 51 | NSMutableDictionary *operationDictionary = [self operationDictionary]; |
52 | [operationDictionary removeObjectForKey:key]; | 52 | [operationDictionary removeObjectForKey:key]; |
53 | } | 53 | } |
-
Please register or login to post a comment