Celebrating WWDC 2022 and the 100th Daily Coding Tip š„³
All tutorials will be free this week!

There is a new API in iOS 16 that makes it easier to deal with and measure time.
Hereās a simple Form
that uses two kinds of clock: a SuspendingClock
, which stops when the app enters the background, and a ContinuousClock
, which... continues.
Each clock has a Stepper
to choose the amount of time you want to wait and a Button
that starts the wait.
As the sleep
function can throw, I am wrapping it in a do-catch
, and it is inside a Task
because otherwise the closure would be asynchronous and unsuitable as the action of a Button
.