For swift check the swift branch. For objective-c check the master branch.
This download manager uses the iOS 7 NSURLSession api to download files.
- Can download large files if app is in background.
- Can download files if app is in background.
- Can download multiple files at a time.
- It can resume interrupted downloads.
- User can also pause the download.
- User can retry any download if any error occurred during download.
- Please note that for resuming downloads server must have resuming support.
- Please note that by using this control your app minimum deployment target will be iOS 7.
See the demo project it is very simple and straight forward. Steps: Copy all files from MZDownloadManager group from sample project.
- Setup your available downloads view controller.
- Initialize MZDownloadManagerViewController and set its delegate. Initialize its downloading array and setup background session configuration. Interrupted downloads can be restore by instance method.
- To add new download task you can use the instance method of MZDownloadManagerViewController.
- (void)addDownloadTask:(NSString *)fileName fileURL:(NSString *)fileURL;
- Use 3 delegate methods
A delegate method called each time whenever new download task is start downloading.
A delegate method called each time whenever any download task is cancelled by the user.
- (void)downloadRequestStarted:(NSURLSessionDownloadTask *)downloadTask;
- (void)downloadRequestCanceled:(NSURLSessionDownloadTask *)downloadTask;A delegate method called each time whenever any download task is finished successfully.
- (void)downloadRequestFinished:(NSString *)fileName;
All steps will look like the following:
Please note that i am using tab based application in sample project.
UINavigationController *mzDownloadingNav = [self.tabBarController.viewControllers objectAtIndex:1]; mzDownloadingViewObj = [mzDownloadingNav.viewControllers objectAtIndex:0]; [mzDownloadingViewObj setDelegate:self]; mzDownloadingViewObj.downloadingArray = [[NSMutableArray alloc] init]; mzDownloadingViewObj.sessionManager = [mzDownloadingViewObj backgroundSession]; [mzDownloadingViewObj populateOtherDownloadTasks];