diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 2bb19bc9..ec031572 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -193,6 +193,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)];