Skip to content

Glossary: Swift Beyond the Basics

Task.sleep

A function that pauses the current task for a given time. It throws a `CancellationError` if the task is canceled, so `try?` is used where the caller can't throw that error.

Where the book teaches it

Related terms

cancellationtry?