Created
July 14, 2015 03:06
-
-
Save barbietunnie/51e330a491571c441c7e 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
/** | |
* Delay the block specified by delay seconds | |
* | |
* With help from http://stackoverflow.com/questions/24034544/dispatch-after-gcd-in-swift/24318861#24318861 | |
*/ | |
func delay(delay:Double, closure:()->()) { | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, | |
Int64(delay * Double(NSEC_PER_SEC)) | |
), | |
dispatch_get_main_queue(), closure) | |
} | |
// Usage | |
delay(0.4) { | |
// do stuff | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment