• Stars
    star
    208
  • Rank 189,015 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 8 years ago
  • Updated over 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A simple and convenient multi task download manager

MCDownloadManager

A simple and convenient multi task download manager

Attention

这个版本默认只支持同时下载10个文件 This version only supports 10 file downloads at the same time.

若要支持更多,请修改下边的代码

configuration.HTTPMaximumConnectionsPerHost = 10;

添加了速度提示(比如:400KB/s)

支持后台和锁屏下载

Installation

Cocoapods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build MCDownloadManager 1.0.0+.

To integrate MCDownloadManager into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'MCDownloadManager', '~> 1.0.3'

Then, run the following command:

$ pod install

Usage

- (void)download {
    [[MCDownloadManager defaultInstance] downloadFileWithURL:self.url
                                                    progress:^(NSProgress * _Nonnull downloadProgress, MCDownloadReceipt *receipt) {
                                                        
                                                        if ([receipt.url isEqualToString:self.url]) {
                                                            self.progressView.progress = downloadProgress.fractionCompleted ;
                                                        }
                                    
                                                    }
                                                 destination:nil
                                                     success:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSURL * _Nonnull filePath) {
                                                         [self.button setTitle:@"播放" forState:UIControlStateNormal];
                                                     }
                                                     failure:^(NSURLRequest * _Nonnull request, NSHTTPURLResponse * _Nullable response, NSError * _Nonnull error) {
                                                         [self.button setTitle:@"重新下载" forState:UIControlStateNormal];
                                                     }];

}