Created
January 24, 2017 16:56
-
-
Save marsicdev/49b592d53f4523f6bbef25ffe347968e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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