Giter Site home page Giter Site logo

sgdownload's Introduction

SGDownload

SGDownload 是一个文件下载器。非常适合用于视频下载,支持后台,锁屏下载。同时支持 iOS、macOS、tvOS 三个平台。

功能特点

  • 使用 NSCondition 条件变量控制并发数、调度下载任务。
  • 封装任务队列(block queue)来管理下载任务。
  • 如下载过程中 App 崩溃,已唤醒的任务继续下载,并在下次启动 App 时同步状态。

使用示例

// 在 AppDelegate 中添加如下代码。
- (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler
{
    [SGDownload handleEventsForBackgroundURLSession:identifier completionHandler:completionHandler];
}

// 启动下载
self.download = [SGDownload download];
[self.download run];
SGDownloadTask * task = [self.download taskWithContentURL:contentURL];
if (!task)
{
    task = [SGDownloadTask taskWithTitle:@“title”
                              contentURL:contentURL
                                 fileURL:fileURL];
}
[self.download addDownloadTask:task];

效果演示

iOS

iOS 效果演示

macOS

macOS 效果演示

sgdownload's People

Contributors

libobjc avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.