Skip to content

a task helper for upload ,download,or other data process

License

Notifications You must be signed in to change notification settings

RabbitJohn/RicTaskHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RicTaskHelper

CI Status Version License Platform

Usage

for downloaing

RicDownloadTask *downloadTask = [[RicDownloadTask alloc] init];

NSDictionary *taskInfo = @{@"downloadUrl":@"http://a4.att.hudong.com/38/47/19300001391844134804474917734_950.png"};

downloadTask.customInfomation = taskInfo;

downloadTask.progressHandle = ^(CGFloat progress){ NSLog(@"progress :%f",progress); };

downloadTask.downloadAction = ^(RicTask* task,CompeletedNotice notice){ NSLog(@"doloading begin");

NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration];

NSURLSession *defaultSession = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: self delegateQueue: [NSOperationQueue mainQueue]];

NSURL *url = [NSURL URLWithString: task.customInfomation[@"downloadUrl"]]; NSURLSessionDownloadTask *dataTask = [defaultSession downloadTaskWithURL: url];

[dataTask resume]; };

RicTaskHelper *helper = [[RicTaskHelper alloc] init]; [helper addTask:downloadTask];

[helper startTasks:^{

} progressHandle:^(NSInteger compeletedCount, NSInteger totalCount) { NSLog(@"%ld/%ld",compeletedCount,totalCount);

} compeleteAction:^{ NSLog(@"compeleted"); }];

for uploading

// prepare for the resouce or resouce information for uploading. RicUploadTask *uploadTask = [[RicUploadTask alloc] init];

uploadTask.customInfomation = @{@"uploadData":@"some data here"};

uploadTask.uploadAction = ^(RicTask task,CompeletedNotice noticeBlock){ // get data from task.customInfomation

/// do you uploading operation here.

// when completed

noticeBlock();

};

RicTaskHelper *uploadHelper = [[RicTaskHelper alloc] init];

[uploadHelper addTask:uploadTask];

[uploadHelper startTasks:^{

// performing UI loading

} progressHandle:^(NSInteger compeletedCount, NSInteger totalCount) {

} compeleteAction:^{

}];

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

RicTaskHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "RicTaskHelper"

Author

zLihuan, [email protected]

License

RicTaskHelper is available under the MIT license. See the LICENSE file for more info.

About

a task helper for upload ,download,or other data process

Resources

License

Stars

Watchers

Forks

Packages

No packages published