O'Reilly logo

iOS® 8 for Programmers: An App-Driven Approach with Swift™, Third Edition by Abbey Deitel, Harvey M. Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

5.3.12 Swift Features Introduced

This section introduces the new Swift language features you’ll see in this app’s code.

while Statement

In Section 5.5.6, you’ll use Swift’s while statement to perform statements repeatedly. The statement consists of the while keyword followed by a condition and a body delimited by required braces ({ and }), as in:

while condition {    statements}

The forin Statement

The forin statement (first used in Section 5.5.3) iterates through a collection of values without using a counter, thus avoiding various common errors, such as off-by-one errors. The syntax of a forin statement is:

for item in collection {    statements}

During each iteration, the forin assigns to item the next value from the collection and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required