Latest0.1.0
Homepagehttps://github.com/hmchuong/iOS-ObjectiveC-HMCDownloadManager
LicenseMIT
Platformsios 8.0
FrameworksUIKit
Authors

Version
License
Platform

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.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 8.0+
  • Xcode 8.3+

Features

  • [x] Download multiple file within a singleton object
  • [x] Support normal and background download
  • [x] Copy to destination file when finish downloading
  • [x] Support pause, resume, cancel downloading an item
  • [x] Auto continue download file after interrupt without cancelling
  • [x] Support multiple callback blocks for same url
  • [x] Write/ read file only, don’t use memory for store download item

Installation

HMCDownloadManager is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'HMCDownloadManager'

Usage

To get default download manager

HMCDownloadManager *defaultDownload = [HMCDownloadManager sharedDefaultManager];

To get background download manager

HMCDownloadManager *backgroundDownload = [HMCDownloadManager sharedBackgroundManager];

To edit maximum waiting time for the next data receiving for default manager

defaultDownload.timeoutForRequest = 5.0;

To edit maximum life time for downloading item

defaultDownload.timeoutForResource = 3600;
backgroundDownload.timeoutForResource = 3600;

To edit maximum downloading items concurrently

defaultDownload.maximumDownloadItems = 10;

To start download from URL

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];

To pause download from URL

[downloadManager pauseDownload:url];

To resume download from URL

[downloadManager resumeDownload:url];

To cancel download from URL

[downloadManager cancelDownload:url];

Author

chuonghuynh, [email protected]

License

HMCDownloadManager is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "HMCDownloadManager",
    "version": "0.1.0",
    "summary": "HMCDownloadManager is a wrapper supporting downloading multiple files within a singleton object",
    "description": "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.",
    "homepage": "https://github.com/hmchuong/iOS-ObjectiveC-HMCDownloadManager",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Chuong M. Huynh": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hmchuong/iOS-ObjectiveC-HMCDownloadManager.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "HMCDownloadManager/Classes/**/*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This