Use async/await with URLSession

Find hereafter a detailed summary of the above named video that belongs to a taxonomy of some WWDC footages.

The original video is available on the official Apple website (session 10095).

"Discover how you can adopt Swift concurrency in URLSession using async/await and AsyncSequence, and how you can apply Swift concurrency concepts to improve your networking code."


The various contents of this speech are indicated hereunder:


Most of the illustrations are parts of the Apple presentations and may be available at the Resources section inside the Overview sheet of each video.

Hereafter, the underlined elements lead directly to the playback of the WWDC video at the appropriate moment.

Async methods #

Preview #

A first approach of the new async methods is pointed out with a code example used to fetch crucial graphic elements used in a demo app.

This code snippet relies on the new async methods introduced in iOS 15 that also embed a cancellation process for more control.



Example #

A detailed code example using AsyncSequence is highlighted to fetch and update the photos of the demo app.



Task delegate #

Basics #

A delegate method is added as an incoming parameter to the new async methods previously introduced in order to be aware of the task process.

Notice that priority is assigned to a task delegate if a session one is concomitantly implemented.

Example #

Based on a new feature of this session demo app, a complete task-specific delegate method is implemented not to mention the errors handling.