nil
完成完成处理程序。编译器给我发出警告:
Consider using asynchronous alternative function
Task {
let foo = await bar() // Yes, using async/await here
// Objc method. Completion is nil because I don't care about the result.
noNeedToWaitForThis(completion: nil) // WARNING: Consider using asynchronous alternative function
}
到目前为止,我发现最好的就是使用一个闭合:
Task {
...
{
noNeedToWaitForThis(completion: nil) // No more warning
}()
}
这在Xcode13.1.
中[编辑]示例目标C方法带回调:
typedef void (^ResponseBlock)(BOOL success, id _Nullable object);
- (void)noNeedToWaitForThisWithCompletion:(nullable ResponseBlock)completion;
xcode 14.3的优点,最简单的静音方法是使用
let _ = ...
。
Task {
...
{ noNeedToWaitForThis(completion: nil) }() // Warning is silenced
}