Skip to content

Instantly share code, notes, and snippets.

@bob910078
Created May 27, 2018 18:19
Show Gist options
  • Save bob910078/7633f2bc71c0578d360a8eeec4a6409c to your computer and use it in GitHub Desktop.
Save bob910078/7633f2bc71c0578d360a8eeec4a6409c to your computer and use it in GitHub Desktop.
// 延遲指定時間 (可搭配 activity indicator 使用)
func delay(_ seconds: Double, completion: @escaping ()->()) {
let dispatchTime: DispatchTime = DispatchTime.now() + Double(Int64(seconds * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC)
DispatchQueue.main.asyncAfter(deadline: dispatchTime) {
completion()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment