1

Xcode has a GCD: Dispatch After code snippet for 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#>
});

What is the equivalent code snippet for Swift?

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Senseful
  • 86,719
  • 67
  • 308
  • 465

1 Answers1

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#>
}

The equivalent of int64_t is Int64, also the block could be called via curly braces at the end of the function call.

Senseful
  • 86,719
  • 67
  • 308
  • 465