DDDownloaderManager
描述
是不是觉得 SDWebImage 太好用了,但是想要使用其他文件又不想那么多解析图片之类的功能?
DDDownloaderManager 就是为此产生的,去除了 SDWebImage 的下载和硬盘缓存功能,增加了部分下载 API 管理功能,增加了批量多线程下载等功能。在工程项目中使用时可以进一步添加其他下载库的实用功能。
推荐入口函数:
使用 request 类发起请求,能够进行简单的请求 API 管理
- (nullable NSMutableArray <id <DDWebObjectCancelOperation>> *)downloadObjectWithRequests:(nullable NSMutableArray <DDDownloaderRequest *> *)requests
options:(DDDownloaderOptions)options
progress:(nullable DDWebObjectDownloaderProgressBlock)progressBlock
singleCompleted:(nullable DDDownloadCompletionBlock)completedBlock
allCompleted:(nullable DDDownloadAllCompletionBlock)allCompleteBlock;
举一个简单粗暴的例子,塞入 urls:
NSMutableArray *testArray = [NSMutableArray array];
for (int i = 0; i < 15; i++) {
[testArray addObject:@"https://www.baidu.com"];
}
[[DDDownloaderManager sharedManager]downloadObjectWithURLS:testArray
options:DDDownloaderRetryFailed progress:^(NSInteger receivedSize, NSInteger expectedSize, NSURL * _Nullable targetURL) {
NSLog(@"progress======%ld,expectedSize========%ld",receivedSize,expectedSize);
}
singleCompleted:^(NSData * _Nullable data, NSError * _Nullable error, BOOL finished, NSURL * _Nullable objectURL, NSString * _Nullable filePath) {
NSLog(@"objectUrl=======%@,result=======%ld,fileUrl======%@",objectURL,finished,filePath);
}
allCompleted:^(BOOL finished) {
NSLog(@"result=======%ld",finished);
}];
其他更多功能请参考 .h 文件内的说明
需求
安装
DDDownloaderManager 通过 CocoaPods 提供。要安装,只需将以下行添加到您的 Podfile 中
pod "DDDownloaderManager"
作者
DDStrongman,[email protected]
许可证
DDDownloaderManager 在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。