JCDownloader
基于AFNetworking的一个有用的iOS下载框架。
特性
此框架支持在ARC下开发iOS 7.0+。
- 独立文件下载开始/暂停/删除操作等。
- 使用groupId的文件列表下载。
- 支持断点下载。
单文件下载
JCDownloadItem *downloadItem = [[JCDownloadItem alloc] init];
downloadItem.downloadUrl = @"download url";
downloadItem.downloadFilePath = @"download file path";
self.operation = [JCDownloadOperation operationWithItem:downloadItem];
[self.operation startWithProgressBlock:^(NSProgress *progress) {
//update progress
} completionBlock:^(NSURL *filePath, NSError *error) {
//download operation completion, do something
}];
[self.operation resetProgressBlock:^(NSProgress *progress) {
//update progress
} completionBlock:^(NSURL *filePath, NSError *error) {
//download operation completion, do something
}];
[self.operation pauseDownload];
[self.operation removeDownload];
文件列表下载
extern NSString *const JCTImageDownloadGroupId;
NSMutableArray *downloadList = [NSMutableArray array];
for (NSInteger index = 0; index < [self urlList].count; index++) {
JCTImageDownloadItem *item = [[JCTImageDownloadItem alloc] init];
item.groupId = JCTImageDownloadGroupId;
item.downloadUrl = [self urlList][index];
item.downloadFilePath = [JCDownloadUtilities filePathWithFileName:[item.downloadUrl lastPathComponent] folderName:@"downloadImages"];
JCDownloadOperation *operation = [JCDownloadOperation operationWithItem:item];
[downloadList addObject:operation];
}
[[JCDownloadQueue sharedQueue] startDownloadList:downloadList];
[[JCDownloadQueue sharedQueue] startDownloadsWithGroupId:JCTImageDownloadGroupId];
[[JCDownloadQueue sharedQueue] pauseDownloadsWithGroupId:JCTImageDownloadGroupId];
[[JCDownloadQueue sharedQueue] removeDownloadsWithGroupId:JCTImageDownloadGroupId];
下载通知
FOUNDATION_EXPORT NSString *const JCDownloadIdKey; ///< download identifier key in notifications userInfo, instance type of the value is NSString.
FOUNDATION_EXPORT NSString *const JCDownloadProgressNotification; ///< notification of download progress.
FOUNDATION_EXPORT NSString *const JCDownloadProgressKey; ///< download progress key in JCDownloadProgressNotification userInfo, instance type of the value is NSProgress.
FOUNDATION_EXPORT NSString *const JCDownloadCompletionNotification; ///< notification of download completion.
FOUNDATION_EXPORT NSString *const JCDownloadCompletionFilePathKey; ///< download completion file path key in JCDownloadCompletionNotification userInfo, instance type of the value is NSURL.
FOUNDATION_EXPORT NSString *const JCDownloadCompletionErrorKey; ///< download completion error key in JCDownloadCompletionNotification userInfo, instance type of the value is NSError.
CocoaPods
要将JCDownloader集成到您的iOS项目中,请在Podfile中指定它
pod 'JCDownloader'
##联系人 如果您对框架有任何问题或建议,请通过电子邮件与我联系。
作者:Joych 电子邮件:[email protected]
许可证
JCDownloader是在MIT许可证下发布的。