Chapter 5
Controlling Program Flow
Although there can be a multitude of ways in which to control program flow in code, often the best approach balances succinctness and readability with performance.
In this chapter, the similarities and differences of each control flow construct in Objective-C and Swift will be examined, and entirely new capabilities in Swift will be introduced.
Let’s begin by covering two new Swift mechanisms for creating representations of iterable sequences that can be used in control flow statements: range operators and stride() functions.
Range Operators
Objective-C includes NSRange, which is a struct representing the location and length index of a series of values. Although it can be used outright to iterate over a range ...
Get Transitioning to Swift now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.