Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COSequence 这个类移除了吗??还是说是自己封装的? #91

Open
KitsGithub opened this issue Aug 7, 2019 · 2 comments
Open

Comments

@KitsGithub
Copy link

请问下COSequence 这个类是自己封装的吗?
内部是使用COCoroutine 生成器去实现批量下载的吗?
而且demo 中 使用

COCoroutine *co1 = xx
[co1  next]

next 方法no found

@NianJi
Copy link
Collaborator

NianJi commented Aug 8, 2019

现在是 COGenerator

@KitsGithub
Copy link
Author

@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);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants