From 81d6bf91a9ab5dde39ad8f39138c64ccd551e562 Mon Sep 17 00:00:00 2001 From: Luis Solano Bonet Date: Wed, 23 Oct 2013 14:20:12 -0400 Subject: [PATCH] Provide background option through the manager --- SDWebImage/SDWebImageDownloader.h | 5 ++++- SDWebImage/SDWebImageManager.h | 8 +++++++- SDWebImage/SDWebImageManager.m | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/SDWebImage/SDWebImageDownloader.h b/SDWebImage/SDWebImageDownloader.h index 229aa41..b248730 100644 --- a/SDWebImage/SDWebImageDownloader.h +++ b/SDWebImage/SDWebImageDownloader.h @@ -24,7 +24,10 @@ typedef enum * (to be combined with `SDWebImageDownloaderUseNSURLCache`). */ SDWebImageDownloaderIgnoreCachedResponse = 1 << 3, - + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ SDWebImageDownloaderContinueInBackground = 1 << 4 } SDWebImageDownloaderOptions; diff --git a/SDWebImage/SDWebImageManager.h b/SDWebImage/SDWebImageManager.h index 4528dcf..b54af25 100644 --- a/SDWebImage/SDWebImageManager.h +++ b/SDWebImage/SDWebImageManager.h @@ -40,7 +40,13 @@ typedef enum * * Use this flag only if you can't make your URLs static with embeded cache busting parameter. */ - SDWebImageRefreshCached = 1 << 4 + SDWebImageRefreshCached = 1 << 4, + + /** + * In iOS 4+, continue the download of the image if the app goes to background. This is achieved by asking the system for + * extra time in background to let the request finish. If the background task expires the operation will be cancelled. + */ + SDWebImageContinueInBackground = 1 << 5 } SDWebImageOptions; typedef void(^SDWebImageCompletedBlock)(UIImage *image, NSError *error, SDImageCacheType cacheType); diff --git a/SDWebImage/SDWebImageManager.m b/SDWebImage/SDWebImageManager.m index a3ecdec..7f558a5 100644 --- a/SDWebImage/SDWebImageManager.m +++ b/SDWebImage/SDWebImageManager.m @@ -144,6 +144,7 @@ if (options & SDWebImageLowPriority) downloaderOptions |= SDWebImageDownloaderLowPriority; if (options & SDWebImageProgressiveDownload) downloaderOptions |= SDWebImageDownloaderProgressiveDownload; if (options & SDWebImageRefreshCached) downloaderOptions |= SDWebImageDownloaderUseNSURLCache; + if (options & SDWebImageContinueInBackground) downloaderOptions |= SDWebImageDownloaderContinueInBackground; if (image && options & SDWebImageRefreshCached) { // force progressive off if image already cached but forced refreshing