Errata: June 11, 2018

Thank you for purchasing iOS Development with Swift. Please post any errors, other than those listed below, in the book's Author Online Forum. We'll compile a comprehensive list and publish it here for everyone's convenience. Thank you!


Chapter 1, Figure 1.5, (p9)

Organization identifier should be com.interactivecoconut

Chapter 1, 1.5.4, (p23)

Replace

"…such as rotating the device, shaking the device, or tapping the device's Home button."

with:

"…such as rotating the device or shaking the device."

Chapter 2, 2.2, first paragraph (p35)

In two places, replace:

"qantity"

with:

"quantitySoup"

Chapter 2, 2.3.3, Step 3, (p38)

Remove the following two sentences because the merge method was introduced in Swift 4:

"Concatenating two dictionaries is, strangely, not available in Swift. In the next chapter, you'll add this functionality to Swift by extending the Dictionary type."

Chapter 3, 3.1, Listing 3.1, (p61)

Change from:

static let feetPerKm:Double = 5280

to:

static let feetPerKm:Double = 3280.84

Chapter 3, Listing 3.3, (p66)

Line of code that reads:

class landline:Telephone {

should have a capital L:

class Landline:Telephone {

Chapter 3, 3.3, Step 3, (p76)

Change from:

"Extensions can add computed properties, but can't add stored properties."

to:

"Extensions can add computed properties, but can't add stored instance properties."

Chapter 3, 3.3.1, Step 3, (p76)

Change from:

"Add a feet computed property."

to:

"Add a feet stored type property."

Chapter 3, 3.3.2, Step 3, (p77)

Replace the following text:

"As you saw in the previous chapter, the dictionary doesn't contain a method to join with another dictionary. Let's rectify this situation!"

with:

"In Swift 4, a new method was introduced to merge two dictionaries, but I think the syntax is a little unwieldy. Let's rectify the situation!"

Chapter 3, 3.3.3, Step 1, (p78)

"Redefine the add method in a Dictionary extension as an overloading of the + operator."

Add the following sentence: "Be sure to overload the operator outside of the Dictionary extension."

Chapter 5, 5.1.2, "Connecting actions from code," (p113)

Remove point 3.

Chapter 5, 5.3, Step 2, (p120)

Change:

"Select Copy items, if needed"

to:

"Select Copy items if needed"

Chapter 5, 5.3.1, Step 1, (p122)

Change:

"If you want your pan to only respond to only one- or two-finger pans..."

to:

"If you want your pan to only respond to one or two-finger pans..."

Chapter 7, Lazy stored property (p173, p174)

Change:

lazy var lettersUpper:String = self.letters.uppercased()

to:

lazy var lettersUpper = letters.uppercased()

Change:

"Notice four additional factors:"

to:

"A couple of points about lazy stored properties:"

Remove these two bullet points:

  • Lazy stored properties based on other instance properties or methods need to specify the self keyword first.
  • To assist the compiler to infer the type of lazy stored properties based on other instance properties, you'll need to explicitly type the variable.
  • Chapter 7, 7.1.2, Step 2, (p177)

    Change:

    "Select the File Inspector for the main storyboard."

    to:

    "Select the File Inspector for the main storyboard and click anywhere in the canvas."

    Chapter 7, 7.2.4 "Nested stack views in Interface Builder," Step 6 (p193)

    Change:

    "Because the text view has an intrinsic content height of its contents..."

    to:

    "Because the text view doesn't have an intrinsic content height..."

    Chapter 8, 8.3 "Observing keyboard notifications," (p205)

    Change:

    "...and you need to know the size of the..."

    to:

    "...and you need to know the position of the..."

    Also change:

    "...about the keyboard, such as its size."

    to:

    "...about the keyboard, such as its position."

    Chapter 8, 8.3.4 "Extracting keyboard information from the notification," (p208, 209)

    Code block in point 1, change:

    var keyboardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey]

    to:

    let keyboardFrame = (userInfo[UIKeyboardFrameEndUserInfoKey]

    Remove point 2

    "To make things more complicated..."

    Renumber points 3 and 4 to points 2 and 3.

    Chapter 8, 8.3.6 "Calculating the offset to animate," (p210)

    After:

    "...and adding in a five-point margin."

    Add:

    "We'll come back to this top constraint in a moment."

    Chapter 9, 9.1.2 "Set up the Model," (p240)

    Change:

    "Great, you can now use this Book class..."

    to:

    "Great, you can now use this Book struct..."

    Chapter 9, 9.1.2 "Creating a Books Manager" (p240)

    Code block in point 1, change:

    private lazy var books: [Book] = self.loadBooks()

    to:

    private lazy var books = loadBooks()

    Chapter 9, 9.2.1 "Embedding a navigation controller," step 2 (p244)

    Change:

    "Double-click in the middle of the navigation bar to open the edit title field and give it the title Books."

    to:

    "Select the navigation bar, open the attributes inspector, and give the scene the title Books."

    Chapter 9, 9.2.1 "Embedding a navigation controller," Step 3, (p244)

    Change:

    "..Find Navigation Bar Item in the Object Library...."

    to:

    "..Find Bar Button Item in the Object Library...."

    Chapter 9, 9.2.4 "Using your delegate protocol," Step 1,2 (p251)

    Change four references to "destinationViewController" to "destination"

    Chapter 10, 10.2.1 "Creating a search controller," Step 3, (p271)

    Change:

    "Turn this off, too: searchController.definesPresentationContext = true "

    to:

    "Turn this on: definesPresentationContext = true "

    Chapter 10, Figure 10.17 "Alternative solutions for sharing data," (p291)

    Dependency injection arrows should go in the reverse direction.

    Chapter 11, 11.2.3 "Adopting Codable Protocol," Step 1, (p313)

    Change:

    class Book: Codable {

    to:

    struct Book: Codable {

    Chapter 11, 11.2.4 "Adding, updating and removing books," Step 3, (p321)

    Change:

    book.id = Int(db.lastInsertRowId())

    to:

    book.id = Int(db.lastInsertRowId)

    Chapter 11, 11.2.4 "Retrieving books from the database," Step 1, (p319)

    Change:

    guard let db = FMDatabase(path: booksFile.path) else {
                  print("unable to create database")
    return nil }

    to:

    let db = FMDatabase(path: booksFile.path)

    Chapter 13, 13.1.2 Adding app icons (p377)

    Remove the following:

    " (although this icon doesn’t need to be included in your app bundle)"

    Chapter 14, 14.2, Step 8, (p413)

    Code block, change from:

        }
    } else {
        // Deal with no error, no book!
    }

    to:

        } else {
            // Deal with no error, no book!
        }
    }

    Add new sentence following code block:

    "As you have done previously, you'll need to surround this try in a do-catch statement."

    Chapter 14, 14.10.2, Step 3, (p430)

    Code block, change from:

    let dataAsJSON = JSON(data: data)

    to:

    let dataAsJSON = try JSON(data: data)

    Add new sentence following code block:

    "As you have done previously, you'll need to surround this try in a do-catch statement."

    Chapter 15, 15.1, fourth bullet point, (p440)

    The following sentence:

    "I've also added properties for these colors in the Book class."

    Should read:

    "I've also added properties for these colors in the Book struct."

    Chapter 15, 15.4.1, point 2, (p449)

    Add an instruction between points 2 and 3:

    "Adopt the CustomStringConvertible protocol:"

    struct Book: Codable, CustomStringConvertible {

    Chapter 15, 15.4.1, point 3, (p449)

    The following sentence:

    "Add a description property to the Book class..."

    should read:

    "Add a description property to the Book struct..."

    Code block:

    override var description: String {

    should read:

    var description: String {

    Chapter 15, 15.5, quote, (p459)

    The following sentence:

    "I've also added properties for these colors in the Book class..."

    should read:

    "I've also added properties for these colors in the Book struct..."