TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Mar 2017 |
Maintained by Orta Therox.
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"); }];
// 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.
RicTaskHelper is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "RicTaskHelper"
zLihuan, [email protected]
RicTaskHelper is available under the MIT license. See the LICENSE file for more info.