断点续传要求下载服务器本身支持 resuming;示例工程需先进入 Example 目录执行 pod install;自定义路径下载时若目标文件夹不存在,需实现 downloadRequestDestinationDoestNotExists 代理,否则走失败回调
MZDownloadManager
mzeeshanidBSD-3-Clause活跃维护基于 NSURLSession 的 iOS 下载管理器,支持多文件并发下载、后台下载大文件,以及应用退出后断点续传。
This download manager uses NSURLSession api to download files. It can download multiple files at a time. It can download large files if app is in background. It can resume downloads if app was quit.
pod "MZDownloadManager"README 未说明;仅要求 iOS 9 及以上部署目标与 Xcode 8
基于 URLSession 的 iOS 下载管理库,支持后台下载、多任务并发与断点续传
基于 NSURLSession 的 iOS 下载管理器,支持多文件并发下载、后台下载大文件,以及应用退出后断点续传。
核心能力
- 用 URLSession 实现文件下载
- 支持 App 在后台时下载大文件
- 可同时下载多个文件
- 支持中断后续传与手动暂停
- 下载出错后可重试任务
容易踩的坑
- 3.3Bug fixes + improvements最新正式版2017-04-27 · 2017-04-27 09:27 UTC
Fixed crashing issues and made some improvements.
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
MZDownloadManager

Features
This download manager uses the URLSession 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.
Usage
To run the example project, clone the repo, and run pod install from the Example directory first.
Requirements
- Xcode 8
- Minimum deployment target is iOS 9.
- For resuming downloads server must have resuming support.
Installation
MZDownloadManager is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "MZDownloadManager"
To install it by using Swift Package Manager:
- In Xcode 11+ Select File > Packages > Add Package Dependency....
- Enter this project's URL: https://github.com/mzeeshanid/MZDownloadManager.git
Update
New helper functions added to support downloading at custom path. Example project is also updated about the usage.
To download file at custom path you can use the following instance method of MZDownloadManager:
public func addDownloadTask(fileName: String, fileURL: String, destinationPath: String)
When download completes:
- It will check if the destination folder still exists then it will move the downloaded file at the specified destination and call success delegate method.
- If destination folder does not exists, following delegate method will provide an opportunity to handle the downloaded file appropriately.
optional func downloadRequestDestinationDoestNotExists(downloadModel: MZDownloadModel, index: Int, location: NSURL)
- If the above delegate method is not implemented then it will just called the failure method.
Important: This delegate method will be called on the session's queue.
Try In a Live App
MZDownloadManager is used in MZFileManager app. To learn more about the app features, visit this page.
Author
Muhammad Zeeshan, [email protected]
If you find MZDownloadManager userful consider donating thanks ;)

License
MZDownloadManager is available under the BSD license. See the LICENSE file for more info.