TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Sep 2015 |
Maintained by cheng kai.
A CKDownloadManager
A Download manager surport resum download. You only implement the delegate.It is simple to use.
You Use it in your project with CocoaPods.
pod 'CKDownloadManager',:git=>"https://github.com/kaich/CKDownloadManager.git"
CKDownloadManager is a download framework.There are more features compare other download Framekwork.The features as below:
Download manager must contain base function as such as start ,pause, resum and delete. CKDownloadManager also contains those. eg: You can start a simple download task as below:
NSString * downloadUrl =@"http://7xl9a5.com2.z0.glb.qiniucdn.com/%E4%B8%AD%E7%8F%AD.mp4?attname=";
CKDownloadBaseModel * model = [[CKDownloadBaseModel alloc] init];
model.URLString = downloadUrl;
[[CKDownloadManager sharedInstance] startDownloadWithURL:URL(downloadUrl) entity: model];
If you want pause it, you can invoke pauseWithURL
as below:
[[CKDownloadManager sharedInstance] pauseWithURL:URL(downloadUrl)];
Of course you can resum as below:
[[CKDownloadManager sharedInstance] resumWithURL:URL(downloadUrl)];
Delete a task as below:
[[CKDownloadManager sharedInstance] deleteWithURL:URL(downloadUrl)];
Delete all downloading task as below:
[[CKDownloadManager sharedInstance] deleteAllWithState:YES];
If you want delete all download completely task, you only change param to NO. Delete All task, you can do it like this.
[[CKDownloadManager sharedInstance] deleteAllWithState:YES];
[[CKDownloadManager sharedInstance] deleteAllWithState:NO];
You can download your many kind of task with CKDownloadManager.You have books and videos.If you want to download those two, you can simple to do this.You only distinguish between them by model.
You have books and videos.You only want to show videos in you tableview.You can use CKDownloadFilter
.Use filterParams
or filterConditionBlock
to set filter condition.For example, you don't want to show png and jpg ,plist, jpeg task.
filter.filterParams=@"NOT(URLString CONTAINS[cd] 'plist' OR URLString CONTAINS[cd] 'jpg' OR URLString CONTAINS[cd] 'png' OR URLString CONTAINS[cd] 'jpeg')";
Of course you also can use filterConditionBlock
to do it.
If you one task depends on another task completely.My download manager also can fit you.
-(void) startDownloadWithURL:(NSURL *)URL entity:(id<CKDownloadModelProtocal>)entity dependencies:(NSDictionary *) dependencyDictionary;
CKDownloadFileValidator
is a validator contains file size , file content and free space validation.If you want wihch validation, you only set the relevant property to yes.
when you want to realize file content validation, you must realize generateValidateCodeWithURL
method in your server.
If you want auto retry,you need set value to retryController
.eg:
CKDownloadRetryController * retryController = [[CKDownloadRetryController alloc] init];
retryController.retryMaxCount=20;
[[CKDownloadManager sharedInstance].retryController = retryController;
It will retry.When many times failed to start to download, the task will move to the bottom of the task and the next will auto start to download
Which network you use in your project? ASIHttpRequest or AFNetworking.You can use CKDownloadManager with either ASIHttpRequest or AFNetworking.Of course you can use any other network lib.Please realize CKHTTPRequestProtocal
and CKHTTPRequestQueueProtocal
.In the lib I have realize it with ASIHttpRequest.Those are ASIHTTPRequest+Download
and ASINetworkQueue+Download
.You can use it as below:
[[CKDownloadManager sharedInstance] setHTTPRequestClass:[ASIHTTPRequest class];
[[CKDownloadManager sharedInstance] setHTTPRequestQueueClass:[ASINetworkQueue class]];
You can create a class inherit CKDownloadBaseModel
or comform to CKDownloadModelProtocal
.You can add your own property in your class.There is a default 'CKDownloadFileModel' which inherit CKDownloadBaseModel
.Detail please refer to LKDBHelper.In the future will surport more database lib.
Performance is important for download.CKDownloadManager has outstanding performance.I have use many thread and synchronization.There are many other strategies to improve performance.
kaich, [email protected]
CKDownloadManager is available under the MIT license. See the LICENSE file for more info.