Latest 1.1.0
Homepage https://github.com/imjoych/JCDownloader
License MIT
Platforms ios 7.0, requires ARC
Dependencies AFNetworking
Authors

A useful iOS downloader framework based on AFNetworking.

Features

This framework supports the development of iOS 7.0+ in ARC.

  • Single file download start/pause/remove operation and so on.
  • File list downloads with groupId.
  • Breakpoint downloading supported.

Single file download

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];

File list downloads

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];

Downloads notifications

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

To integrate JCDownloader into your iOS project, specify it in your Podfile:

pod 'JCDownloader'

Contacts

If you have any questions or suggestions about the framework, please E-mail to contact me.

Author: Joych
E-mail: [email protected]

License

JCDownloader is released under the MIT License.

Latest podspec

{
    "name": "JCDownloader",
    "version": "1.1.0",
    "license": "MIT",
    "summary": "A useful iOS download framework based on AFNetworking.",
    "homepage": "https://github.com/imjoych/JCDownloader",
    "authors": {
        "ChenJianjun": "[email protected]"
    },
    "source": {
        "git": "https://github.com/imjoych/JCDownloader.git",
        "tag": "1.1.0"
    },
    "source_files": "JCDownloader/*.{h,m}",
    "platforms": {
        "ios": "7.0"
    },
    "requires_arc": true,
    "dependencies": {
        "AFNetworking": [
            "~> 3.2.0"
        ]
    }
}

Pin It on Pinterest

Share This