Head First Swift
1st Edition
Addendum and Notes
With the latest version of Swift Playgrounds (4.0), it’s easier if you choose the “Playground” template when creating a new Playground when following the book’s exercises and activities.
Errata and Corrections
Chapter 4
Functions deal in values
The function multiplyBy42 should read:
func multiplyBy42(_ number: Int) {
let result = number * 42
print("The number multiplied by 42 is: \(result)")
}
The version in the book attempts to assign the result of multiplying number * 42 back to number, but because of the way functions work number is a constant and cannot be modified. This revised version creates a constant named result and uses that, and then prints it.
Code Download
We’ve prepared a bundle of code, based on the exercises, activities, and puzzles in the book. We recommend you only download it if you’re having trouble, or want to skip ahead. The book will otherwise guide you through everything you need.
You can also visit GitHub and clone the repository, if you’re comfortable with that.
Below is a summary of some interesting bits and pieces you’ll find in the download:
/Chapter_10/
The HF_Swift_Chapter_10.playgroundbook containing a variety of exercises and solutions
The Todo List app, for Xcode
Questions and Feedback
If you have any questions or feedback about Head First Swift 1st Edition, we’re happy to help. Please use the form below or reach out to @parisba on Twitter.