Created
January 8, 2016 18:10
-
-
Save nathanhillyer/648d24b510992d63d164 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
import Foundation | |
/** | |
Executes the closure on the main queue after a set amount of seconds. | |
- parameter delay: Delay in seconds | |
- parameter closure: Code to execute after delay | |
*/ | |
func delayOnMainQueue(delay: Double, closure: ()->()) { | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC))), dispatch_get_main_queue(), closure) | |
} | |
/** | |
Executes the closure on a background queue after a set amount of seconds. | |
- parameter delay: Delay in seconds | |
- parameter closure: Code to execute after delay | |
*/ | |
func delayOnBackgroundQueue(delay: Double, closure: ()->()) { | |
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, Int64(delay * Double(NSEC_PER_SEC))), dispatch_get_global_queue(QOS_CLASS_UTILITY, 0), closure) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment