• Stars
    star
    165
  • Rank 221,634 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created about 7 years ago
  • Updated almost 5 years ago

Reviews

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

Repository Details

A delightful big files download framework for iOS, OS X, watchOS, and tvOS.

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 效果演示