在Swift之后发送的示例

Sen*_*ful 1 grand-central-dispatch swift

Xcode有一个GCD:Dispatch After Objective-C的代码片段:

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    <#code to be executed after a specified delay#>
});
Run Code Online (Sandbox Code Playgroud)

Swift的等效代码片段是什么?

Sen*_*ful 10

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (Int64)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue()) {
    <#code to be executed after a specified delay#>
}
Run Code Online (Sandbox Code Playgroud)

相当于int64_tInt64,也块可经由花括号在函数调用结束时调用.