测试测试版 | ✗ |
Lang语言 | Obj-CObjective C |
许可证 | BSD 3.0 |
发布最新发布 | 2015年3月 |
由 Alberto De Bortoli 维护。
iOS 的下载管理器。实际上,需要下载文件而不需要任何外部库。
目标
如果您想使用 CocoaPods 将此组件作为 pod 包含,只需在 Podfile 中添加以下行:pod "ADBDownloadManager"
尝试包含的示例项目或直接运行 pod try ADBDownloadManager
来测试。
简单用法
ADBDownloadManager.h
DownloadManager
NSString *documentsDirectory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
// without base URL
self.downloadManager = [[ADBDownloadManager alloc] initWithLocalPathFolder:documentsDirectory];
// or with base URL
self.downloadManager = [[ADBDownloadManager alloc] initWithBaseRemoteURL:@"http://www.myservice.com/"
localPathFolder:documentsDirectory];
self.downloadManager.forceDownoad = YES; // overwrites files, default is NO
self.downloadManager.createFoldersHierarchy = NO; // avoid the creation of the folders hierarchy, default is YES
delegate
和 dataSource
self.downloadManager.delegate = self;
self.downloadManager.dataSource = self;
[self.downloadManager start];
ADBDownloadManagerDataSource
协议#pragma mark - ADBDownloadManagerDataSource
- (NSUInteger)numberOfFilesToDownloadForDownloadManager:(ADBDownloadManager *)manager { ... }
- (NSString *)downloadManager:(ADBDownloadManager *)manager
pathForFileToDownloadAtIndex:(NSUInteger)index { ... }
ADBDownloadManagerDelegate
协议#pragma mark - ADBDownloadManagerDataSource
- (void)downloadManager:(ADBDownloadManager *)manager
didDownloadFileAtIndex:(NSUInteger)index
fromRemoteURL:(NSString *)remoteURL
toLocalPath:(NSString *)localPath
bytes:(NSUInteger)bytes { ... }
- (void)downloadManager:(ADBDownloadManager *)manager
didFailFileAtIndex:(NSUInteger)index
fromRemoteURL:(NSString *)remoteURL
toLocalPath:(NSString *)localPath
error:(NSError *)error { ... }
- (void)downloadManagerDidCompleteAllDownloads:(ADBDownloadManager *)manager
failedURLs:(NSArray *)failedURLs
totalBytes:(NSUInteger)totalBytes { ... }
- (void)downloadManagerWillStart:(ADBDownloadManager *)manager { ... }
- (void)downloadManagerDidStop:(ADBDownloadManager *)manager { ... }
[self.downloadManager start];
[self.downloadManager stop];
就这么简单。
许可在新版 BSD 许可证下。
版权所有 © 2012, Alberto De Bortoli 保留所有权利。
在满足以下条件的情况下,允许重新分配和使用源代码和二进制形式,无论是否修改:* 源代码重新分配必须保留上述版权声明、本条件列表和以下免责声明。* 二进制形式的重新分配必须在文档中或随重新分配的提供其他材料中复制上述版权声明、本条件列表和以下免责声明。* 未经特定事先书面许可,不得使用 Alberto De Bortoli 或其贡献者的名称作为推广或支持从本软件派生的产品的标识。
本软件由版权所有者和贡献者按照“现状”提供,并且不提供任何明示或暗示的保证,包括但不限于对适销性和针对特定目的适用性的暗示保证。在任何情况下,Alberto De Bortoli均不对因使用本软件而产生的任何直接、间接、偶然、特殊、示范性或后果性损害(包括但不限于替代商品或服务的采购;使用、数据或利润的损失;或业务中断)承担任何责任,无论这种损害是由于何种原因引起的,无论基于何种责任理论,无论是在合同、严格责任还是侵权法上(包括疏忽或其它)。