From 78a50d39296b2e04cb9ca6c59ee9c694dcd2669c Mon Sep 17 00:00:00 2001 From: derpoliuk Date: Tue, 13 May 2014 11:11:36 +0300 Subject: [PATCH] Adds -[SDWebImageManager saveImageToCache:forURL:] method --- SDWebImage/SDWebImageManager.h | 10 ++++++++++ SDWebImage/SDWebImageManager.m | 7 +++++++ 2 files changed, 17 insertions(+) diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 45598c46..adadbe17 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -187,6 +187,16 @@ SDWebImageManager *manager = [SDWebImageManager sharedManager]; progress:(SDWebImageDownloaderProgressBlock)progressBlock completed:(SDWebImageCompletedWithFinishedBlock)completedBlock; +/** + * Saves image to cache for given URL + * + * @param image The image to cache + * @param url The URL to the image + * + */ + +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url; + /** * Cancel all current opreations */ diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index af3d1b80..4e813c8b 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -215,6 +215,13 @@ return operation; } +- (void)saveImageToCache:(UIImage *)image forURL:(NSURL *)url { + if (image && url) { + NSString *key = [self cacheKeyForURL:url]; + [self.imageCache storeImage:image forKey:key toDisk:YES]; + } +} + - (void)cancelAll { @synchronized (self.runningOperations) { [self.runningOperations makeObjectsPerformSelector:@selector(cancel)];