RicTaskHelper 0.1.8

RicTaskHelper 0.1.8

测试已测试
Lang语言 Obj-CObjective C
许可证 MIT
发布最后发布2017年3月

Orta Therox维护。



  • 作者
  • zLihuan

用法

下载

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(@"下载开始";

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(@"完成"); }];

上传

// 准备要上传的资源或资源信息 RicUploadTask *uploadTask = [[RicUploadTask alloc] init];

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

uploadTask.uploadAction = ^(RicTask task,CompeletedNotice noticeBlock){ // 从task.customInfomation获取数据

/// 在这里进行上传操作。

// 当完成时

noticeBlock();

};

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

[uploadHelper addTask:uploadTask];

[uploadHelper startTasks:^{

// 执行UI加载

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

} compeleteAction:^{

}];

要运行示例项目,请克隆仓库,并首先从Example目录运行pod install

需求

安装

RicTaskHelper可通过CocoaPods获得。要安装它,只需将以下行添加到Podfile中

pod "RicTaskHelper"

作者

zLihuan, [email protected]

许可证

RicTaskHelper在MIT许可证下可用。有关更多信息,请参阅LICENSE文件。