帮酷LOGO
  • 显示原文与译文双语对照的内容
王颖博-封装下载器

  • 源代码名称:MCDownloadManager
  • 源代码网址:http://www.github.com/agelessman/MCDownloadManager
  • MCDownloadManager源代码文档
  • MCDownloadManager源代码下载
  • Git URL:
    git://www.github.com/agelessman/MCDownloadManager.git
  • Git Clone代码到本地:
    git clone http://www.github.com/agelessman/MCDownloadManager
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/agelessman/MCDownloadManager
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
  • 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];
                                                         }];
    }



    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语