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
This commit is contained in:
Bogdan Poplauschi 2014-06-25 21:32:53 +03:00
parent 23874cdca4
commit a6f11b3ad7
14 changed files with 128 additions and 63 deletions

View File

@ -20,7 +20,7 @@
* Note that because of the limitations of categories this property can get out of sync * Note that because of the limitations of categories this property can get out of sync
* if you use sd_setImage: directly. * if you use sd_setImage: directly.
*/ */
- (NSURL *)imageURL; - (NSURL *)sd_imageURL;
/** /**
* Set the imageView `image` with an `url`. * Set the imageView `image` with an `url`.
@ -102,13 +102,15 @@
/** /**
* Cancel the current download * Cancel the current download
*/ */
- (void)cancelCurrentImageLoad; - (void)sd_cancelCurrentImageLoad;
@end @end
@interface MKAnnotationView (WebCacheDeprecated) @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 __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 __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:`"); - (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 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)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 @end

View File

@ -14,7 +14,7 @@ static char imageURLKey;
@implementation MKAnnotationView (WebCache) @implementation MKAnnotationView (WebCache)
- (NSURL *)imageURL { - (NSURL *)sd_imageURL {
return objc_getAssociatedObject(self, &imageURLKey); return objc_getAssociatedObject(self, &imageURLKey);
} }
@ -59,7 +59,7 @@ static char imageURLKey;
} }
}); });
}]; }];
[self setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"]; [self sd_setImageLoadOperation:operation forKey:@"MKAnnotationViewImage"];
} else { } else {
dispatch_main_async_safe(^{ dispatch_main_async_safe(^{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@ -70,8 +70,8 @@ static char imageURLKey;
} }
} }
- (void)cancelCurrentImageLoad { - (void)sd_cancelCurrentImageLoad {
[self cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"]; [self sd_cancelImageLoadOperationWithKey:@"MKAnnotationViewImage"];
} }
@end @end
@ -79,6 +79,10 @@ static char imageURLKey;
@implementation MKAnnotationView (WebCacheDeprecated) @implementation MKAnnotationView (WebCacheDeprecated)
- (NSURL *)imageURL {
return [self sd_imageURL];
}
- (void)setImageWithURL:(NSURL *)url { - (void)setImageWithURL:(NSURL *)url {
[self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil]; [self sd_setImageWithURL:url placeholderImage:nil options:0 completed:nil];
} }
@ -115,4 +119,8 @@ static char imageURLKey;
}]; }];
} }
- (void)cancelCurrentImageLoad {
[self sd_cancelCurrentImageLoad];
}
@end @end

View File

@ -14,6 +14,13 @@
* *
* @return the content type as string (i.e. image/jpeg, image/gif) * @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 @end

View File

@ -8,7 +8,7 @@
@implementation NSData (ImageContentType) @implementation NSData (ImageContentType)
+ (NSString *)contentTypeForImageData:(NSData *)data { + (NSString *)sd_contentTypeForImageData:(NSData *)data {
uint8_t c; uint8_t c;
[data getBytes:&c length:1]; [data getBytes:&c length:1];
switch (c) { switch (c) {
@ -38,3 +38,12 @@
} }
@end @end
@implementation NSData (ImageContentTypeDeprecated)
+ (NSString *)contentTypeForImageData:(NSData *)data {
return [self sd_contentTypeForImageData:data];
}
@end

View File

@ -17,14 +17,14 @@
/** /**
* Get the current image URL. * Get the current image URL.
*/ */
- (NSURL *)currentImageURL; - (NSURL *)sd_currentImageURL;
/** /**
* Get the image URL for a control state. * 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. * @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`. * Set the imageView `image` with an `url`.
@ -192,18 +192,21 @@
/** /**
* Cancel the current image download * Cancel the current image download
*/ */
- (void)cancelImageLoadForState:(UIControlState)state; - (void)sd_cancelImageLoadForState:(UIControlState)state;
/** /**
* Cancel the current backgroundImage download * Cancel the current backgroundImage download
*/ */
- (void)cancelBackgroundImageLoadForState:(UIControlState)state; - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state;
@end @end
@interface UIButton (WebCacheDeprecated) @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 __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 __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:`"); - (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 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)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 @end

View File

@ -14,7 +14,7 @@ static char imageURLStorageKey;
@implementation UIButton (WebCache) @implementation UIButton (WebCache)
- (NSURL *)currentImageURL { - (NSURL *)sd_currentImageURL {
NSURL *url = self.imageURLStorage[@(self.state)]; NSURL *url = self.imageURLStorage[@(self.state)];
if (!url) { if (!url) {
@ -24,7 +24,7 @@ static char imageURLStorageKey;
return url; return url;
} }
- (NSURL *)imageURLForState:(UIControlState)state { - (NSURL *)sd_imageURLForState:(UIControlState)state {
return self.imageURLStorage[@(state)]; return self.imageURLStorage[@(state)];
} }
@ -51,7 +51,7 @@ static char imageURLStorageKey;
- (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock {
[self setImage:placeholder forState:state]; [self setImage:placeholder forState:state];
[self cancelImageLoadForState:state]; [self sd_cancelImageLoadForState:state];
if (!url) { if (!url) {
[self.imageURLStorage removeObjectForKey:@(state)]; [self.imageURLStorage removeObjectForKey:@(state)];
@ -82,7 +82,7 @@ static char imageURLStorageKey;
} }
}); });
}]; }];
[self setImageLoadOperation:operation forState:state]; [self sd_setImageLoadOperation:operation forState:state];
} }
- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state { - (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state {
@ -106,7 +106,7 @@ static char imageURLStorageKey;
} }
- (void)sd_setBackgroundImageWithURL:(NSURL *)url forState:(UIControlState)state placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletionBlock)completedBlock { - (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]; [self setBackgroundImage:placeholder forState:state];
@ -125,7 +125,7 @@ static char imageURLStorageKey;
} }
}); });
}]; }];
[self setBackgroundImageLoadOperation:operation forState:state]; [self sd_setBackgroundImageLoadOperation:operation forState:state];
} else { } else {
dispatch_main_async_safe(^{ dispatch_main_async_safe(^{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@ -136,20 +136,20 @@ static char imageURLStorageKey;
} }
} }
- (void)setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { - (void)sd_setImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
[self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
} }
- (void)cancelImageLoadForState:(UIControlState)state { - (void)sd_cancelImageLoadForState:(UIControlState)state {
[self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]]; [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonImageOperation%@", @(state)]];
} }
- (void)setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state { - (void)sd_setBackgroundImageLoadOperation:(id<SDWebImageOperation>)operation forState:(UIControlState)state {
[self setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; [self sd_setImageLoadOperation:operation forKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
} }
- (void)cancelBackgroundImageLoadForState:(UIControlState)state { - (void)sd_cancelBackgroundImageLoadForState:(UIControlState)state {
[self cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]]; [self sd_cancelImageLoadOperationWithKey:[NSString stringWithFormat:@"UIButtonBackgroundImageOperation%@", @(state)]];
} }
- (NSMutableDictionary *)imageURLStorage { - (NSMutableDictionary *)imageURLStorage {
@ -168,6 +168,14 @@ static char imageURLStorageKey;
@implementation UIButton (WebCacheDeprecated) @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 { - (void)setImageWithURL:(NSURL *)url forState:(UIControlState)state {
[self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil]; [self sd_setImageWithURL:url forState:state placeholderImage:nil options:0 completed:nil];
} }
@ -242,7 +250,11 @@ static char imageURLStorageKey;
- (void)cancelCurrentImageLoad { - (void)cancelCurrentImageLoad {
// in a backwards compatible manner, cancel for current state // 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 @end

View File

@ -33,7 +33,7 @@
for (size_t i = 0; i < count; i++) { for (size_t i = 0; i < count; i++) {
CGImageRef image = CGImageSourceCreateImageAtIndex(source, i, NULL); 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]]; [images addObject:[UIImage imageWithCGImage:image scale:[UIScreen mainScreen].scale orientation:UIImageOrientationUp]];
@ -52,7 +52,7 @@
return animatedImage; return animatedImage;
} }
+ (float)frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source { + (float)sd_frameDurationAtIndex:(NSUInteger)index source:(CGImageSourceRef)source {
float frameDuration = 0.1f; float frameDuration = 0.1f;
CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil); CFDictionaryRef cfFrameProperties = CGImageSourceCopyPropertiesAtIndex(source, index, nil);
NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties; NSDictionary *frameProperties = (__bridge NSDictionary *)cfFrameProperties;

View File

@ -19,7 +19,7 @@
+ (UIImage *)sd_imageWithData:(NSData *)data { + (UIImage *)sd_imageWithData:(NSData *)data {
UIImage *image; UIImage *image;
NSString *imageContentType = [NSData contentTypeForImageData:data]; NSString *imageContentType = [NSData sd_contentTypeForImageData:data];
if ([imageContentType isEqualToString:@"image/gif"]) { if ([imageContentType isEqualToString:@"image/gif"]) {
image = [UIImage sd_animatedGIFWithData:data]; image = [UIImage sd_animatedGIFWithData:data];
} }

View File

@ -82,7 +82,7 @@
/** /**
* Cancel the current download * Cancel the current download
*/ */
- (void)cancelCurrentHighlightedImageLoad; - (void)sd_cancelCurrentHighlightedImageLoad;
@end @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 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)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 @end

View File

@ -30,7 +30,7 @@
} }
- (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { - (void)sd_setHighlightedImageWithURL:(NSURL *)url options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
[self cancelCurrentHighlightedImageLoad]; [self sd_cancelCurrentHighlightedImageLoad];
if (url) { if (url) {
__weak UIImageView *wself = self; __weak UIImageView *wself = self;
@ -48,7 +48,7 @@
} }
}); });
}]; }];
[self setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey]; [self sd_setImageLoadOperation:operation forKey:UIImageViewHighlightedWebCacheOperationKey];
} else { } else {
dispatch_main_async_safe(^{ dispatch_main_async_safe(^{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@ -59,8 +59,8 @@
} }
} }
- (void)cancelCurrentHighlightedImageLoad { - (void)sd_cancelCurrentHighlightedImageLoad {
[self cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey]; [self sd_cancelImageLoadOperationWithKey:UIImageViewHighlightedWebCacheOperationKey];
} }
@end @end
@ -100,4 +100,8 @@
}]; }];
} }
- (void)cancelCurrentHighlightedImageLoad {
[self sd_cancelCurrentHighlightedImageLoad];
}
@end @end

View File

@ -50,7 +50,7 @@
* Note that because of the limitations of categories this property can get out of sync * Note that because of the limitations of categories this property can get out of sync
* if you use sd_setImage: directly. * if you use sd_setImage: directly.
*/ */
- (NSURL *)imageURL; - (NSURL *)sd_imageURL;
/** /**
* Set the imageView `image` with an `url`. * Set the imageView `image` with an `url`.
@ -148,22 +148,24 @@
/** /**
* Download an array of images and starts them in an animation loop * Download an array of images and starts them in an animation loop
* *
*@param arrayOfURLs An array of NSURL * @param arrayOfURLs An array of NSURL
*/ */
- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs; - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs;
/** /**
* Cancel the current download * Cancel the current download
*/ */
- (void)cancelCurrentImageLoad; - (void)sd_cancelCurrentImageLoad;
- (void)cancelCurrentAnimationImagesLoad; - (void)sd_cancelCurrentAnimationImagesLoad;
@end @end
@interface UIImageView (WebCacheDeprecated) @interface UIImageView (WebCacheDeprecated)
- (NSURL *)imageURL __deprecated_msg("Use `sd_imageURL`");
- (void)setImageWithURL:(NSURL *)url __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:`"); - (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 __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`"); - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options`");
@ -173,6 +175,10 @@
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock __deprecated_msg("Method deprecated. Use `sd_setImageWithURL:placeholderImage:options: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)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:`"); - (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:`");
- (void)cancelCurrentArrayLoad __deprecated_msg("Use `cancelCurrentAnimationImagesLoad`"); - (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs __deprecated_msg("Use `sd_setAnimationImagesWithURLs:`");
- (void)cancelCurrentArrayLoad __deprecated_msg("Use `sd_cancelCurrentAnimationImagesLoad`");
- (void)cancelCurrentImageLoad __deprecated_msg("Use `cancelCurrentImageLoad`");
@end @end

View File

@ -39,7 +39,7 @@ static char imageURLKey;
} }
- (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock { - (void)sd_setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletionBlock)completedBlock {
[self cancelCurrentImageLoad]; [self sd_cancelCurrentImageLoad];
objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(self, &imageURLKey, url, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
if (!(options & SDWebImageDelayPlaceholder)) { if (!(options & SDWebImageDelayPlaceholder)) {
@ -66,7 +66,7 @@ static char imageURLKey;
} }
}); });
}]; }];
[self setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"]; [self sd_setImageLoadOperation:operation forKey:@"UIImageViewImageLoad"];
} else { } else {
dispatch_main_async_safe(^{ dispatch_main_async_safe(^{
NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}]; NSError *error = [NSError errorWithDomain:@"SDWebImageErrorDomain" code:-1 userInfo:@{NSLocalizedDescriptionKey : @"Trying to load a nil url"}];
@ -77,12 +77,12 @@ static char imageURLKey;
} }
} }
- (NSURL *)imageURL { - (NSURL *)sd_imageURL {
return objc_getAssociatedObject(self, &imageURLKey); return objc_getAssociatedObject(self, &imageURLKey);
} }
- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs { - (void)sd_setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
[self cancelCurrentAnimationImagesLoad]; [self sd_cancelCurrentAnimationImagesLoad];
__weak UIImageView *wself = self; __weak UIImageView *wself = self;
NSMutableArray *operationsArray = [[NSMutableArray alloc] init]; NSMutableArray *operationsArray = [[NSMutableArray alloc] init];
@ -109,15 +109,15 @@ static char imageURLKey;
[operationsArray addObject:operation]; [operationsArray addObject:operation];
} }
[self setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"]; [self sd_setImageLoadOperation:[NSArray arrayWithArray:operationsArray] forKey:@"UIImageViewAnimationImages"];
} }
- (void)cancelCurrentImageLoad { - (void)sd_cancelCurrentImageLoad {
[self cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"]; [self sd_cancelImageLoadOperationWithKey:@"UIImageViewImageLoad"];
} }
- (void)cancelCurrentAnimationImagesLoad { - (void)sd_cancelCurrentAnimationImagesLoad {
[self cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"]; [self sd_cancelImageLoadOperationWithKey:@"UIImageViewAnimationImages"];
} }
@end @end
@ -125,6 +125,10 @@ static char imageURLKey;
@implementation UIImageView (WebCacheDeprecated) @implementation UIImageView (WebCacheDeprecated)
- (NSURL *)imageURL {
return [self sd_imageURL];
}
- (void)setImageWithURL:(NSURL *)url { - (void)setImageWithURL:(NSURL *)url {
[self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil]; [self sd_setImageWithURL:url placeholderImage:nil options:0 progress:nil completed:nil];
} }
@ -151,7 +155,6 @@ static char imageURLKey;
completedBlock(image, error, cacheType); completedBlock(image, error, cacheType);
} }
}]; }];
} }
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock { - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options completed:(SDWebImageCompletedBlock)completedBlock {
@ -160,7 +163,6 @@ static char imageURLKey;
completedBlock(image, error, cacheType); completedBlock(image, error, cacheType);
} }
}]; }];
} }
- (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock { - (void)setImageWithURL:(NSURL *)url placeholderImage:(UIImage *)placeholder options:(SDWebImageOptions)options progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedBlock)completedBlock {
@ -169,11 +171,18 @@ static char imageURLKey;
completedBlock(image, error, cacheType); completedBlock(image, error, cacheType);
} }
}]; }];
} }
- (void)cancelCurrentArrayLoad { - (void)cancelCurrentArrayLoad {
[self cancelCurrentAnimationImagesLoad]; [self sd_cancelCurrentAnimationImagesLoad];
}
- (void)cancelCurrentImageLoad {
[self sd_cancelCurrentImageLoad];
}
- (void)setAnimationImagesWithURLs:(NSArray *)arrayOfURLs {
[self sd_setAnimationImagesWithURLs:arrayOfURLs];
} }
@end @end

View File

@ -17,20 +17,20 @@
* @param operation the operation * @param operation the operation
* @param key key for storing the operation * @param key key for storing the operation
*/ */
- (void)setImageLoadOperation:(id)operation forKey:(NSString *)key; - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key;
/** /**
* Cancel all operations for the current UIView and key * Cancel all operations for the current UIView and key
* *
* @param key key for identifying the operations * @param key key for identifying the operations
*/ */
- (void)cancelImageLoadOperationWithKey:(NSString *)key; - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key;
/** /**
* Just remove the operations corresponding to the current UIView and key without cancelling them * Just remove the operations corresponding to the current UIView and key without cancelling them
* *
* @param key key for identifying the operations * @param key key for identifying the operations
*/ */
- (void)removeImageLoadOperationWithKey:(NSString *)key; - (void)sd_removeImageLoadOperationWithKey:(NSString *)key;
@end @end

View File

@ -23,13 +23,13 @@ static char loadOperationKey;
return operations; return operations;
} }
- (void)setImageLoadOperation:(id)operation forKey:(NSString *)key { - (void)sd_setImageLoadOperation:(id)operation forKey:(NSString *)key {
[self cancelImageLoadOperationWithKey:key]; [self sd_cancelImageLoadOperationWithKey:key];
NSMutableDictionary *operationDictionary = [self operationDictionary]; NSMutableDictionary *operationDictionary = [self operationDictionary];
[operationDictionary setObject:operation forKey:key]; [operationDictionary setObject:operation forKey:key];
} }
- (void)cancelImageLoadOperationWithKey:(NSString *)key { - (void)sd_cancelImageLoadOperationWithKey:(NSString *)key {
// Cancel in progress downloader from queue // Cancel in progress downloader from queue
NSMutableDictionary *operationDictionary = [self operationDictionary]; NSMutableDictionary *operationDictionary = [self operationDictionary];
id operations = [operationDictionary objectForKey:key]; id operations = [operationDictionary objectForKey:key];
@ -47,7 +47,7 @@ static char loadOperationKey;
} }
} }
- (void)removeImageLoadOperationWithKey:(NSString *)key { - (void)sd_removeImageLoadOperationWithKey:(NSString *)key {
NSMutableDictionary *operationDictionary = [self operationDictionary]; NSMutableDictionary *operationDictionary = [self operationDictionary];
[operationDictionary removeObjectForKey:key]; [operationDictionary removeObjectForKey:key];
} }