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 5. Flow Control and More

This chapter is a miscellany. I’ll start by describing Swift’s flow control constructs for branching, looping, and jumping. Then, I’ll summarize Swift’s privacy and introspection features, and talk about how to override operators and how to create your own operators. Next, I’ll explain some specialized aspects of Swift memory management. Finally, I’ll survey some relatively recent Swift language features: synthesized protocol implementations, key paths, instance as function, dynamic members, property wrappers, custom string interpolation, reverse generics, result builders, and Result.

Flow Control

A computer program has a path of execution through its code statements. Normally, this path follows a simple rule: execute each statement in succession. But there is another possibility. Flow control can be used to make the path of execution skip some statements, or go back and repeat some statements.

Flow control is what makes a computer program “intelligent.” By testing in real time the truth value of a condition — an expression that evaluates to a Bool and is thus true or false — the program decides at that moment how to proceed. Flow control based on testing a condition may be divided into two general types:

Branching

The code is divided into alternative chunks, like roads that diverge in a wood, and the program is presented with a choice of possible ways to go; the truth of a condition is used to determine which chunk will actually be executed. ...

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