Skip to content

Instantly share code, notes, and snippets.

@akimach
Last active June 9, 2016 11:31
Show Gist options
  • Select an option

  • Save akimach/7c003a50718c8ee1c98a158afc7d8e2c to your computer and use it in GitHub Desktop.

Select an option

Save akimach/7c003a50718c8ee1c98a158afc7d8e2c to your computer and use it in GitHub Desktop.
N秒後に処理を実行する
// n秒後に与えられた処理を行う
func execAfterSec(n: Double, completion: (()->())?) {
let delay = 1.0 * Double(NSEC_PER_SEC)
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(delay))
dispatch_after(time, dispatch_get_main_queue(), {
completion!()
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment