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
  • 307,833
  • 40
  • 508
  • 550
Senseful
  • 79,995
  • 61
  • 289
  • 423

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
  • 79,995
  • 61
  • 289
  • 423