Last active
January 29, 2016 23:21
-
-
Save nbasham/6cb30a2a898d9a862497 to your computer and use it in GitHub Desktop.
Run a block on the main thread after a specified number of seconds.
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 | |
public class ThreadUtil : NSObject { | |
// Run a block on the main thread after a specified number of seconds, thanks raywenderlich.com for splaining it so well | |
public static func runOnMainThreadAfterDelay(delaySeconds: Double, closure: () -> ()) { | |
let startTime = dispatch_time(DISPATCH_TIME_NOW, Int64(delaySeconds * Double(NSEC_PER_SEC))) | |
dispatch_after(startTime, dispatch_get_main_queue(), closure) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment