Created
January 31, 2015 04:33
-
-
Save mobyjames/2cada52ee78fb2bed909 to your computer and use it in GitHub Desktop.
Delay Block
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
func delaySeconds(seconds: Double, closure: ()->()) { | |
dispatch_after( | |
dispatch_time( | |
DISPATCH_TIME_NOW, | |
Int64(seconds * Double(NSEC_PER_SEC)) | |
), | |
dispatch_get_main_queue(), | |
closure | |
) | |
} |
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
delaySeconds(2.0) { | |
println("2 seconds have passed.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment