Skip to content

Commit a6f11b3

Browse files
committed
Fixed #775, made sure all the category methods that are public have the sd_ prefix (deprecated the old ones)
-there were a few exceptions where I just renamed the methods since they were added in this method
1 parent 23874cd commit a6f11b3

14 files changed

+128
-63
lines changed

SDWebImage/MKAnnotationView+WebCache.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Note that because of the limitations of categories this property can get out of sync
2121
* if you use sd_setImage: directly.
2222
*/
23-
- (NSURL *)imageURL;
23+
- (NSURL *)sd_imageURL;
2424

2525
/**
2626
* Set the imageView `image` with an `url`.
@@ -102,13 +102,15 @@
102102
/**
103103
* Cancel the current download
104104
*/
105-
- (void)cancelCurrentImageLoad;
105+
- (void)sd_cancelCurrentImageLoad;
106106

107107
@end
108108

109109

110110
@interface MKAnnotationView (WebCacheDeprecated)
111111

112+
- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`");
113+
112114
- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`");
113115
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`");
114116
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`");
@@ -117,4 +119,6 @@
117119
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`");
118120
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`");
119121

122+
- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`");
123+
120124
@end

SDWebImage/MKAnnotationView+WebCache.m

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@implementation MKAnnotationView (WebCache)
1616

17-
- (NSURL *)imageURL {
17+
- (NSURL *)sd_imageURL {
1818
return objc_getAssociatedObject(self, &imageURLKey);
1919
}
2020

@@ -59,7 +59,7 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
5959
}
6060
});
6161
}];
62-
[self setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"];
62+
[self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"];
6363
} else {
6464
dispatch_main_async_safe(^{
6565
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@@ -70,15 +70,19 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
7070
}
7171
}
7272

73-
- (void)cancelCurrentImageLoad {
74-
[self cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"];
73+
- (void)sd_cancelCurrentImageLoad {
74+
[self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"];
7575
}
7676

7777
@end
7878

7979

8080
@implementation MKAnnotationView (WebCacheDeprecated)
8181

82+
- (NSURL *)imageURL {
83+
return [self sd_imageURL];
84+
}
85+
8286
- (void)setImageWithURL:(NSURL *)url {
8387
[self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil];
8488
}
@@ -115,4 +119,8 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder opt
115119
}];
116120
}
117121

122+
- (void)cancelCurrentImageLoad {
123+
[self sd_cancelCurrentImageLoad];
124+
}
125+
118126
@end

SDWebImage/NSData+ImageContentType.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,13 @@
1414
*
1515
* @return the content type as string (i.e. image/jpeg, image/gif)
1616
*/
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:`");
1825

1926
@end

SDWebImage/NSData+ImageContentType.m

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
@implementation NSData (ImageContentType)
1010

11-
+ (NSString *)contentTypeForImageData:(NSData *)data {
11+
+ (NSString *)sd_contentTypeForImageData:(NSData *)data {
1212
uint8_t c;
1313
[data getBytes:&c length:1];
1414
switch (c) {
@@ -38,3 +38,12 @@ + (NSString *)contentTypeForImageData:(NSData *)data {
3838
}
3939

4040
@end
41+
42+
43+
@implementation NSData (ImageContentTypeDeprecated)
44+
45+
+ (NSString *)contentTypeForImageData:(NSData *)data {
46+
return [self sd_contentTypeForImageData:data];
47+
}
48+
49+
@end

SDWebImage/UIButton+WebCache.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
/**
1818
* Get the current image URL.
1919
*/
20-
- (NSURL *)currentImageURL;
20+
- (NSURL *)sd_currentImageURL;
2121

2222
/**
2323
* Get the image URL for a control state.
2424
*
2525
* @param state Which state you want to know the URL for. The values are described in UIControlState.
2626
*/
27-
- (NSURL *)imageURLForState:(UIControlState)state;
27+
- (NSURL *)sd_imageURLForState:(UIControlState)state;
2828

2929
/**
3030
* Set the imageView `image` with an `url`.
@@ -192,18 +192,21 @@
192192
/**
193193
* Cancel the current image download
194194
*/
195-
- (void)cancelImageLoadForState:(UIControlState)state;
195+
- (void)sd_cancelImageLoadForState:(UIControlState)state;
196196

197197
/**
198198
* Cancel the current backgroundImage download
199199
*/
200-
- (void)cancelBackgroundImageLoadForState:(UIControlState)state;
200+
- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state;
201201

202202
@end
203203

204204

205205
@interface UIButton (WebCacheDeprecated)
206206

207+
- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`");
208+
- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`");
209+
207210
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`");
208211
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`");
209212
- (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 @@
220223
- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`");
221224
- (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:`");
222225

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:`");
224228

225229
@end

SDWebImage/UIButton+WebCache.m

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
@implementation UIButton (WebCache)
1616

17-
- (NSURL *)currentImageURL {
17+
- (NSURL *)sd_currentImageURL {
1818
NSURL *url = self.imageURLStorage[@(self.state)];
1919

2020
if (!url) {
@@ -24,7 +24,7 @@ - (NSURL *)currentImageURL {
2424
return url;
2525
}
2626

27-
- (NSURL *)imageURLForState:(UIControlState)state {
27+
- (NSURL *)sd_imageURLForState:(UIControlState)state {
2828
return self.imageURLStorage[@(state)];
2929
}
3030

@@ -51,7 +51,7 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold
5151
- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
5252

5353
[self setImage:placeholder forState:state];
54-
[self cancelImageLoadForState:state];
54+
[self sd_cancelImageLoadForState:state];
5555

5656
if (!url) {
5757
[self.imageURLStorage removeObjectForKey:@(state)];
@@ -82,7 +82,7 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold
8282
}
8383
});
8484
}];
85-
[self setImageLoadOperation:operation forState:state];
85+
[self sd_setImageLoadOperation:operation forState:state];
8686
}
8787

8888
- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
@@ -106,7 +106,7 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
106106
}
107107

108108
- (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];
110110

111111
[self setBackgroundImage:placeholder forState:state];
112112

@@ -125,7 +125,7 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
125125
}
126126
});
127127
}];
128-
[self setBackgroundImageLoadOperation:operation forState:state];
128+
[self sd_setBackgroundImageLoadOperation:operation forState:state];
129129
} else {
130130
dispatch_main_async_safe(^{
131131
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@@ -136,20 +136,20 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
136136
}
137137
}
138138

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)]];
141141
}
142142

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)]];
145145
}
146146

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)]];
149149
}
150150

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)]];
153153
}
154154

155155
- (NSMutableDictionary *)imageURLStorage {
@@ -168,6 +168,14 @@ - (NSMutableDictionary *)imageURLStorage {
168168

169169
@implementation UIButton (WebCacheDeprecated)
170170

171+
- (NSURL *)currentImageURL {
172+
return [self sd_currentImageURL];
173+
}
174+
175+
- (NSURL *)imageURLForState:(UIControlState)state {
176+
return [self sd_imageURLForState:state];
177+
}
178+
171179
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
172180
[self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
173181
}
@@ -242,7 +250,11 @@ - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state pl
242250

243251
- (void)cancelCurrentImageLoad {
244252
// 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];
246258
}
247259

248260
@end

SDWebImage/UIImage+GIF.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
3333
for (size_t i = 0; i < count; i++) {
3434
CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
3535

36-
duration += [self frameDurationAtIndex:i source:source];
36+
duration += [self sd_frameDurationAtIndex:i source:source];
3737

3838
[images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
3939

@@ -52,7 +52,7 @@ + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
5252
return animatedImage;
5353
}
5454

55-
+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
55+
+ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
5656
float frameDuration = 0.1f;
5757
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
5858
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;

SDWebImage/UIImage+MultiFormat.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ @implementation UIImage (MultiFormat)
1919

2020
+ (UIImage *)sd_imageWithData:(NSData *)data {
2121
UIImage *image;
22-
NSString *imageContentType = [NSData contentTypeForImageData:data];
22+
NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
2323
if ([imageContentType isEqualToString:@"image/gif"]) {
2424
image = [UIImage sd_animatedGIFWithData:data];
2525
}

SDWebImage/UIImageView+HighlightedWebCache.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
/**
8383
* Cancel the current download
8484
*/
85-
- (void)cancelCurrentHighlightedImageLoad;
85+
- (void)sd_cancelCurrentHighlightedImageLoad;
8686

8787
@end
8888

@@ -95,4 +95,6 @@
9595
- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`");
9696
- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`");
9797

98+
- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`");
99+
98100
@end

SDWebImage/UIImageView+HighlightedWebCache.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
3030
}
3131

3232
- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
33-
[self cancelCurrentHighlightedImageLoad];
33+
[self sd_cancelCurrentHighlightedImageLoad];
3434

3535
if (url) {
3636
__weak UIImageView *wself = self;
@@ -48,7 +48,7 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
4848
}
4949
});
5050
}];
51-
[self setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
51+
[self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
5252
} else {
5353
dispatch_main_async_safe(^{
5454
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@@ -59,8 +59,8 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
5959
}
6060
}
6161

62-
- (void)cancelCurrentHighlightedImageLoad {
63-
[self cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
62+
- (void)sd_cancelCurrentHighlightedImageLoad {
63+
[self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
6464
}
6565

6666
@end
@@ -100,4 +100,8 @@ - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)optio
100100
}];
101101
}
102102

103+
- (void)cancelCurrentHighlightedImageLoad {
104+
[self sd_cancelCurrentHighlightedImageLoad];
105+
}
106+
103107
@end

0 commit comments

Comments
 (0)