除了sync和async之外,他们的文档中的差异让我感到困惑。他们的github page上的例子看起来仍然是同步调用的延续。
continueWith()
Adds a synchronous continuation to this task, returning a new task that completes after the continuation has finished running.
continueWithTask()
Adds an asynchronous continuation to this task, returning a new task that completes after the task returned by the continuation has completed.
答案 0 :(得分:5)
如果您有帮助方法返回continueWith()
个对象,则无法使用onSuccess()
或Task
,因为Bolts代码不会将其视为Task
并等待执行。它会将Task<Task<Void>>
视为简单的数据结果。
基本上,这不起作用,因为此链的结果任务是update().onSuccess(new Continuation<ParseObject, Task<Void>>()
{
public Task<Void> then(Task<ParseObject> task) throws Exception
{
return Task.delay(3000);
}
}) // this end returns a Task<Task<Void>>
:
Task<Void>
但是这会有效,链条会返回update().onSuccessTask(new Continuation<ParseObject, Task<Void>>()
{
public Task<Void> then(Task<ParseObject> task) throws Exception
{
return Task.delay(3000);
}
}) // this end returns a Task<Void>
:
**//.h**
@interface ShipClass : SKSpriteNode
{
//extra cool stuff here
}
- (instancetype)initWithImageNamed:(NSString *)name
@end