Skip to content

Instantly share code, notes, and snippets.

@correia
Created January 27, 2016 03:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save correia/68c75e449cdd1c4943dc to your computer and use it in GitHub Desktop.
Save correia/68c75e449cdd1c4943dc to your computer and use it in GitHub Desktop.
// What does this program print?
import Foundation
for (var i = 0; i < 5; i++) {
let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(1 * Double(NSEC_PER_SEC)))
dispatch_after(delayTime, dispatch_get_main_queue()) {
print(i)
}
}
NSRunLoop.currentRunLoop().runUntilDate(NSDate(timeIntervalSinceNow: 5.0))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment