Skip to content

Instantly share code, notes, and snippets.

@minikin
Created May 3, 2019 15:15
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 minikin/736ce562cba4ec25060759d00a5687cb to your computer and use it in GitHub Desktop.
Save minikin/736ce562cba4ec25060759d00a5687cb to your computer and use it in GitHub Desktop.
delay swift
func delay(by duration: TimeInterval, line: UInt = #line, execute: @escaping () -> Void) {
print("delaying line \(line) by \(duration)")
DispatchQueue.main.asyncAfter(deadline: .now() + duration) {
execute()
print("executed line \(line)")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment