Skip to content

基于NSOperationQueue与NSURLSessionDataTask实现的文件下载器(支持设置队列并发数量、任务优先级、断点续传)。

Notifications You must be signed in to change notification settings

zhengmiaokai/MKWebFileDownloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 

Repository files navigation

MKWebFileDownloader

基于NSOperationQueue与NSURLSessionDataTask实现的文件下载器(支持设置队列并发数量、任务优先级、断点续传)

- (void)download {
    [MKWebFileDownloader sharedInstance].delegateOnMainThread = YES;
    [MKWebFileDownloader sharedInstance].maxConcurrentOperationCount = 6;

    NSString *URLString = @"https://dldir1.qq.com/qqfile/QQforMac/QQ_V6.5.0.dmg";
    [[MKWebFileDownloader sharedInstance] downloadWithURLString:URLString supportResume:YES directory:nil queuePriority:NSOperationQueuePriorityNormal progressHandler:^(NSInteger receivedSize, NSInteger expectedSize) {
        NSString *statusInfo = [NSString stringWithFormat:@"下载进度:%d%@", (int)(1.0*receivedSize/expectedSize * 100), @"%"];
        NSLog(@"%@", statusInfo);
    } completionHandler:^(NSString *filePath, NSData *fileData, NSError *error) {
        NSLog(@"下载完成");
    }];
}

WeChat16372c25ff834ee3641a00cd173912f4

About

基于NSOperationQueue与NSURLSessionDataTask实现的文件下载器(支持设置队列并发数量、任务优先级、断点续传)。

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages