Skip to Content
iOS 15 Programming Fundamentals with Swift
book

iOS 15 Programming Fundamentals with Swift

by Matt Neuburg
October 2021
Intermediate to advanced content levelIntermediate to advanced
786 pages
21h 17m
English
O'Reilly Media, Inc.
Book available
Content preview from iOS 15 Programming Fundamentals with Swift

Chapter 6. Structured Concurrency

The term concurrency refers to the ability of a computer program to do more than one thing at the same time. When you’re programming iOS, the runtime uses concurrency constantly; if it didn’t, your app would be less responsive to the user — perhaps completely unresponsive.

For the most part, the various Cocoa frameworks use concurrency behind the scenes on your behalf; you don’t have to worry about concurrency because the frameworks are worrying about them for you.

For instance, suppose your app is downloading something from the network. This download doesn’t happen all by itself; somewhere, someone is running code that interacts with the network and obtains data. Yet none of that interferes with your code, or prevents the user from tapping and swiping things in your interface. The networking code runs “in the background.” That’s concurrency in action.

Nevertheless, sometimes you need to be concerned with concurrency explicitly. For example:

Receiving a communication from background code

Let’s say your app has asked to download something from the network. Presumably, that’s because you want that thing. If you’re downloading an image, the goal might be to display that image in your interface, or to store that image as a file saved to disk. The runtime, in code that you can’t see, does the downloading in the background, but eventually it will finish; it has obtained the image. Now your code needs a way to receive that image so that it can do ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

iOS 15 Programming for Beginners - Sixth Edition

iOS 15 Programming for Beginners - Sixth Edition

Ahmad Sahar, Craig Clayton
Programming iOS 14

Programming iOS 14

Matt Neuburg

Publisher Resources

ISBN: 9781098118495Supplemental ContentErrata Page