HMCDownloadManager is a wrapper supporting downloading multiple files within a singleton object. By download multiple files concurrently (same or not same URL), we can set maximumDownloadItem for number of maximum items can be downloaded concurrently. We can choose between background (items can be downloaded when app is in background) or default download manager. Callback each block for each item in different queues.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- iOS 8.0+
- Xcode 8.3+
- Download multiple file within a singleton object
- Support normal and background download
- Copy to destination file when finish downloading
- Support pause, resume, cancel downloading an item
- Auto continue download file after interrupt without cancelling
- Support multiple callback blocks for same url
- Write/ read file only, don't use memory for store download item
HMCDownloadManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'HMCDownloadManager'
HMCDownloadManager *defaultDownload = [HMCDownloadManager sharedDefaultManager];
HMCDownloadManager *backgroundDownload = [HMCDownloadManager sharedBackgroundManager];
defaultDownload.timeoutForRequest = 5.0;
defaultDownload.timeoutForResource = 3600;
backgroundDownload.timeoutForResource = 3600;
defaultDownload.maximumDownloadItems = 10;
dispatch_queue_t downloadQueue = dispatch_queue_create("Image Downloader", DISPATCH_QUEUE_SERIAL);
[defaultDownload startDownloadFromURL:url
progressBlock:^(NSURL *sourceUrl, NSString *identifier, int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
// Update UI progress
} destination:^NSURL *(NSURL *sourceUrl, NSString *identifier) {
// return destination file
} finishBlock:^(NSURL *sourceUrl, NSString *identifier, NSURL *fileLocation, NSError *error) {
// Update when finished downloading
} queue:downloadQueue];
[downloadManager pauseDownload:url];
[downloadManager resumeDownload:url];
[downloadManager cancelDownload:url];
chuonghuynh, minhchuong.itus@gmail.com
HMCDownloadManager is available under the MIT license. See the LICENSE file for more info.