LoginSignup
1
1

More than 1 year has passed since last update.

Swift Concurrency で遅延実行

Posted at

Swift Concurrency な環境で DispatchQueue を書きたくないので

コード

Before

DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) {
  print("遅延処理")
}

After

Task {
  try await Task.sleep(nanoseconds: 1_000_000_000)
  print("遅延処理")
}

参考

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1