Skip to content

Instantly share code, notes, and snippets.

@marsicdev
Created January 24, 2017 16:56
Show Gist options
  • Save marsicdev/49b592d53f4523f6bbef25ffe347968e to your computer and use it in GitHub Desktop.
Save marsicdev/49b592d53f4523f6bbef25ffe347968e to your computer and use it in GitHub Desktop.
// Swift 2
let triggerTime = (Int64(NSEC_PER_SEC) * 10)
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, triggerTime), dispatch_get_main_queue(), { () -> Void in
self.functionToCall()
})
// Swift 3
unowned let unownedSelf = self
let deadlineTime = DispatchTime.now() + .seconds(10)
DispatchQueue.main.asyncAfter(deadline: deadlineTime, execute: {
unownedSelf.functionToCall()
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment