Permalink
Browse files

Fixed #775, made sure all the category methods that are public have t…

…he sd_ prefix (deprecated the old ones)

-there were a few exceptions where I just renamed the methods since they were added in this method
  • Loading branch information...
1 parent 23874cd commit a6f11b3ad77a54853b5198dcd3523b2153396883 @bpoplauschi bpoplauschi committed Jun 25, 2014
@@ -20,7 +20,7 @@
* Note that because of the limitations of categories this property can get out of sync
* if you use sd_setImage: directly.
*/
-- (NSURL *)imageURL;
+- (NSURL *)sd_imageURL;
/**
* Set the imageView `image` with an `url`.
@@ -102,13 +102,15 @@
/**
* Cancel the current download
*/
-- (void)cancelCurrentImageLoad;
+- (void)sd_cancelCurrentImageLoad;
@end
@interface MKAnnotationView (WebCacheDeprecated)
+- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`");
+
- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`");
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:`");
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:`");
@@ -117,4 +119,6 @@
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:completed:`");
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options:completed:`");
+- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelCurrentImageLoad`");
+
@end
@@ -14,7 +14,7 @@
@implementation MKAnnotationView (WebCache)
-- (NSURL *)imageURL {
+- (NSURL *)sd_imageURL {
return objc_getAssociatedObject(self, &imageURLKey);
}
@@ -59,7 +59,7 @@ - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder
}
});
}];
- [self setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"];
+ [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"];
} else {
dispatch_main_async_safe(^{
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
}
}
-- (void)cancelCurrentImageLoad {
- [self cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"];
+- (void)sd_cancelCurrentImageLoad {
+ [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"];
}
@end
@implementation MKAnnotationView (WebCacheDeprecated)
+- (NSURL *)imageURL {
+ return [self sd_imageURL];
+}
+
- (void)setImageWithURL:(NSURL *)url {
[self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil];
}
@@ -115,4 +119,8 @@ - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder opt
}];
}
+- (void)cancelCurrentImageLoad {
+ [self sd_cancelCurrentImageLoad];
+}
+
@end
@@ -14,6 +14,13 @@
*
* @return the content type as string (i.e. image/jpeg, image/gif)
*/
-+ (NSString *)contentTypeForImageData:(NSData *)data;
++ (NSString *)sd_contentTypeForImageData:(NSData *)data;
+
+@end
+
+
+@interface NSData (ImageContentTypeDeprecated)
+
++ (NSString *)contentTypeForImageData:(NSData *)data __deprecated_msg("Use `sd_contentTypeForImageData:`");
@end
@@ -8,7 +8,7 @@
@implementation NSData (ImageContentType)
-+ (NSString *)contentTypeForImageData:(NSData *)data {
++ (NSString *)sd_contentTypeForImageData:(NSData *)data {
uint8_t c;
[data getBytes:&c length:1];
switch (c) {
@@ -38,3 +38,12 @@ + (NSString *)contentTypeForImageData:(NSData *)data {
}
@end
+
+
+@implementation NSData (ImageContentTypeDeprecated)
+
++ (NSString *)contentTypeForImageData:(NSData *)data {
+ return [self sd_contentTypeForImageData:data];
+}
+
+@end
@@ -17,14 +17,14 @@
/**
* Get the current image URL.
*/
-- (NSURL *)currentImageURL;
+- (NSURL *)sd_currentImageURL;
/**
* Get the image URL for a control state.
*
* @param state Which state you want to know the URL for. The values are described in UIControlState.
*/
-- (NSURL *)imageURLForState:(UIControlState)state;
+- (NSURL *)sd_imageURLForState:(UIControlState)state;
/**
* Set the imageView `image` with an `url`.
@@ -192,18 +192,21 @@
/**
* Cancel the current image download
*/
-- (void)cancelImageLoadForState:(UIControlState)state;
+- (void)sd_cancelImageLoadForState:(UIControlState)state;
/**
* Cancel the current backgroundImage download
*/
-- (void)cancelBackgroundImageLoadForState:(UIControlState)state;
+- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state;
@end
@interface UIButton (WebCacheDeprecated)
+- (NSURL *)currentImageURL __deprecated_msg("Use `sd_currentImageURL`");
+- (NSURL *)imageURLForState:(UIControlState)state __deprecated_msg("Use `sd_imageURLForState:`");
+
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:`");
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:forState:placeholderImage:`");
- (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 @@
- (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setBackgroundImageWithURL:forState:placeholderImage:completed:`");
- (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:`");
-- (void)cancelCurrentImageLoad __deprecated_msg("Use `cancelImageLoadForState:`");
+- (void)cancelCurrentImageLoad __deprecated_msg("Use `sd_cancelImageLoadForState:`");
+- (void)cancelBackgroundImageLoadForState:(UIControlState)state __deprecated_msg("Use `sd_cancelBackgroundImageLoadForState:`");
@end
@@ -14,7 +14,7 @@
@implementation UIButton (WebCache)
-- (NSURL *)currentImageURL {
+- (NSURL *)sd_currentImageURL {
NSURL *url = self.imageURLStorage[@(self.state)];
if (!url) {
@@ -24,7 +24,7 @@ - (NSURL *)currentImageURL {
return url;
}
-- (NSURL *)imageURLForState:(UIControlState)state {
+- (NSURL *)sd_imageURLForState:(UIControlState)state {
return self.imageURLStorage[@(state)];
}
@@ -51,7 +51,7 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold
- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
[self setImage:placeholder forState:state];
- [self cancelImageLoadForState:state];
+ [self sd_cancelImageLoadForState:state];
if (!url) {
[self.imageURLStorage removeObjectForKey:@(state)];
@@ -82,7 +82,7 @@ - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placehold
}
});
}];
- [self setImageLoadOperation:operation forState:state];
+ [self sd_setImageLoadOperation:operation forState:state];
}
- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
@@ -106,7 +106,7 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
}
- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
- [self cancelImageLoadForState:state];
+ [self sd_cancelImageLoadForState:state];
[self setBackgroundImage:placeholder forState:state];
@@ -125,7 +125,7 @@ - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state
}
});
}];
- [self setBackgroundImageLoadOperation:operation forState:state];
+ [self sd_setBackgroundImageLoadOperation:operation forState:state];
} else {
dispatch_main_async_safe(^{
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
}
}
-- (void)setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
- [self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
+- (void)sd_setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
+ [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
}
-- (void)cancelImageLoadForState:(UIControlState)state {
- [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
+- (void)sd_cancelImageLoadForState:(UIControlState)state {
+ [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
}
-- (void)setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
- [self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
+- (void)sd_setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
+ [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
}
-- (void)cancelBackgroundImageLoadForState:(UIControlState)state {
- [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
+- (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state {
+ [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
}
- (NSMutableDictionary *)imageURLStorage {
@@ -168,6 +168,14 @@ - (NSMutableDictionary *)imageURLStorage {
@implementation UIButton (WebCacheDeprecated)
+- (NSURL *)currentImageURL {
+ return [self sd_currentImageURL];
+}
+
+- (NSURL *)imageURLForState:(UIControlState)state {
+ return [self sd_imageURLForState:state];
+}
+
- (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
[self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
}
@@ -242,7 +250,11 @@ - (void)setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state pl
- (void)cancelCurrentImageLoad {
// in a backwards compatible manner, cancel for current state
- [self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(self.state)]];
+ [self sd_cancelImageLoadForState:self.state];
+}
+
+- (void)cancelBackgroundImageLoadForState:(UIControlState)state {
+ [self sd_cancelBackgroundImageLoadForState:state];
}
@end
View
@@ -33,7 +33,7 @@ + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
for (size_t i = 0; i < count; i++) {
CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL);
- duration += [self frameDurationAtIndex:i source:source];
+ duration += [self sd_frameDurationAtIndex:i source:source];
[images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
@@ -52,7 +52,7 @@ + (UIImage *)sd_animatedGIFWithData:(NSData *)data {
return animatedImage;
}
-+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
++ (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
float frameDuration = 0.1f;
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;
@@ -19,7 +19,7 @@ @implementation UIImage (MultiFormat)
+ (UIImage *)sd_imageWithData:(NSData *)data {
UIImage *image;
- NSString *imageContentType = [NSData contentTypeForImageData:data];
+ NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
if ([imageContentType isEqualToString:@"image/gif"]) {
image = [UIImage sd_animatedGIFWithData:data];
}
@@ -82,7 +82,7 @@
/**
* Cancel the current download
*/
-- (void)cancelCurrentHighlightedImageLoad;
+- (void)sd_cancelCurrentHighlightedImageLoad;
@end
@@ -95,4 +95,6 @@
- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:completed:`");
- (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setHighlightedImageWithURL:options:progress:completed:`");
+- (void)cancelCurrentHighlightedImageLoad __deprecated_msg("Use `sd_cancelCurrentHighlightedImageLoad`");
+
@end
@@ -30,7 +30,7 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
}
- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
- [self cancelCurrentHighlightedImageLoad];
+ [self sd_cancelCurrentHighlightedImageLoad];
if (url) {
__weak UIImageView *wself = self;
@@ -48,7 +48,7 @@ - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)op
}
});
}];
- [self setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
+ [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
} else {
dispatch_main_async_safe(^{
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
}
}
-- (void)cancelCurrentHighlightedImageLoad {
- [self cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
+- (void)sd_cancelCurrentHighlightedImageLoad {
+ [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
}
@end
@@ -100,4 +100,8 @@ - (void)setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)optio
}];
}
+- (void)cancelCurrentHighlightedImageLoad {
+ [self sd_cancelCurrentHighlightedImageLoad];
+}
+
@end
Oops, something went wrong.

0 comments on commit a6f11b3

Please sign in to comment.