COSequence 这个类移除了吗??还是说是自己封装的?
KitsGithub opened this issue · comments
请问下COSequence
这个类是自己封装的吗?
内部是使用COCoroutine
生成器去实现批量下载的吗?
而且demo 中 使用
COCoroutine *co1 = xx
[co1 next]
next 方法no found
现在是 COGenerator
@NianJi
在调用 COProgressPromise
为什么一直打印 test
我使用的是实例的代码
static COProgressPromise* progressDownloadFileFromUrl(NSString *url){
COProgressPromise *promise = [COProgressPromise promise];
[NSURLSession sharedSession].configuration.requestCachePolicy = NSURLRequestReloadIgnoringCacheData;
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:[NSURL URLWithString:url] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error) {
[promise reject:error];
}
else{
[promise fulfill:data];
}
}];
[task resume];
// setup progress
[promise setupWithProgress:task.progress];
return promise;
}
co_launch(^{
COProgressPromise *promise = progressDownloadFileFromUrl(@"http://img17.3lian.com/d/file/201701/17/9a0d018ba683b9cbdcc5a7267b90891c.jpg");
for(id p in promise){
double v = [p doubleValue];
NSLog(@"current progress: %f", (float)v);
}
// get the download result
NSData *data = await(promise);
// handle data
});
而且运行的时候这句会报错,得注释掉才可以
NSData *data = await(promise);