Errata in iOS Programming, 6th Ed

Chapter 7: Localization, page 137

It’s the old switcheroo…

When the segmented control was added to the WorldTrotter Map (page 108) it was done in the order Standard, Hybrid, Satellite.

But when it’s localized on page 137, both the struck-out code and the new code use the order Standard, Satellite, Hybrid.

Not surprisingly, this new order cascades upon itself. In addition to being carried over to the screenshot of the running app on page 139, the order of the strings in Localizable.strings (as shown on page 138) is based on the order in the source file.

(Correcting this by changing just the struck-out code is not sufficient, of course, since other code checks which absolute segment was touched.)

Chapter 8: Controlling Animations, page 146

We override viewWillAppear(_:slight_smile: to set questionLabel.alpha = 0…but the only time we call animateLabelTransitions() is when showNextQuestion(_:slight_smile: is invoked.

When the app is first launched, viewWIllAppear(_:slight_smile: is invoked but not showNextQuestion(_:slight_smile: so questionLabel.alpha is left at 0 and the first question does not display.

Thus, it seems we should also call animateLabelTransitions() at the end of viewWillAppear(_:).

(Side note: if we DO add animateLabelTransitions() to the end of viewWillAppear(_:), then on page 147, when we tweak viewDidLoad() to set currentQuestionLabel.text, we should instead tweak nextQuestionLabel.text instead, since animateLabelTransitions() will transition the currentQuestionLabel alpha to 0 and the nextQuestionAlpha to 1.)

The download solution provided for Chapter 24 is still using Swift 2, not Swift 3. It need to be updated to Swift 3

Not sure if this is just an Xcode version issue, I’m using 8.2.1… but in chapter 4, p. 73 (of version purchased through pearson I think it was), the instructions follow:

The interface doesn’t seem to have the indicated instruction “Resolve Auto Layout Issues menu, and select Update Frames from the All Views in View Controller section.”

Instead I used the update button while the background view was selected and I THINK that does the same thing.

This is not correct. The reason you are having problems is you are not using all the parameters in the method. You are missing for: indexPath. It should look like this.

let cell = tableView.dequeueReusableCell(withIdentifier: “UITableViewCell”, for: indexPath)

You also have to set the Identifier in the cell prototype attributes inspector to UITableViewCell

A few minor things:
pg 35, let fmStation = 91.1 gives actual Swift results of 91.09999999999999
pg 35, Swift results are ordered differently for let nameByParkingSpace = [13: “Alice”, 27: “Bob”] – [27: “Bob”, 13: “Alice”]
pg 36, Swift results again ordered differently, let availableRooms = Set([205, 411, 412]) – {411, 205, 412} – I frankly don’t understand this one

Just a note. For Adding more constraints on page 67-68, following the given instructions does not work if some of the labels overlap, as it won’t identify the nearest neighbor correctly. You could end up with labels piled on each other.

Chapter 14, UINavigationController

On page 250, the code for dismissing the keyboard using a UITapGestureRecognizer is incorrect.

It should be

self.view.endEditing(true)

Chapter 7, page 137

When I go to the terminal and enter “genstrings MapViewController.swift” and return, nothing happens. No file named Localizable.strings appears.

I solved it. I did not close xcode. It has to be closed for the file to appear in finder.

Chapter 15 in the “Solutions” folder. If you test this, there will be an error in the ImageStore file:

let cache = NSCache<String, UIImage>()

Change this line to:

let cache = NSCache<NSString, UIImage>()

The following source code (citation auto generated by kindle below) doesn’t take into account the semantics of shouldChangeCharactersIn when the user is pasting text. If the pasted text changes some of the digits and contains a decimal, but is replacing a decimal the paste won’t work. This is an edge case, but the real problem is that it clouds the semantics of shouldChangeCharactersIn for someone new to that function.

let existingTextHasDecimalSeparator = textField.text?. range( of: ".") let replacementTextHasDecimalSeparator = string.range( of: ".") if existingTextHasDecimalSeparator != nil, replacementTextHasDecimalSeparator != nil { return false } else { return true }

Keur,Christian; Hillegass,Aaron. iOS Programming: The Big Nerd Ranch Guide (Big Nerd Ranch Guides) (Kindle Locations 2211-2214). Big Nerd Ranch Guides. Kindle Edition.

If this errata is accepted I would appreciate knowing via direct message or email, sqh@me.com.

re: selectedIndexPaths array
@ Chap 23: Core Data Relationships: Adding Tags To The Interface, location 9238

Text mentions selectedIndexPaths here:
“In TagsViewController.swift, add the appropriate index paths to the selectedIndexPaths array.”

But, instruction to add this array was omitted, and doesn’t show in book code.
Did find it in downloaded source code.

Omitted line should be:

var selectedIndexPaths = [IndexPath]()

Minor grammar error.

Page 321
Chapter 18: Touch Events and UIResponder
Section: Drawing with DrawView
Para 1

An instance of DrawView needs to be able draw lines.

Should be

An instance of DrawView needs to be able to draw lines.

In Chapter 2, P.32, Figure 3.2 A Playground. Just a tip, I am always forced to add the line import PlaygroundSupport to a Playground while running xCode 8 on my macBook plus. Otherwise, the Playground just endlessly spins and the code never executes.

On page 183, in the Figure 10.6 Homepwner object Diagram, I believe there is a relationship arrow missing between ItemsViewController and ItemStore. The Controller has access to the store, as stated on the following page, 184 “Giving the controller access to the store” section. We added a property for an ItemStore to the ItemsViewController, thus establishing a relationship between the two. Update the diagram to show the connection between the controller and the model (ItemStore).

I am having an issue with chapter-6 page 115. It shows to put the line:

"let segmentControl = UISegmentControl(items: [“Standard”. “Hybrid”, “Satellite”])

Inside the “loadview” function but that gives me an error.

I moved it outside the function and that fixed it but now in chapter-7 it is giving me an error saying "cannot use instance member standardString within property initializers.

Image-1 is the error I get in chapter-6 (could not load this one being new I can only upload one image) and Image-2 is the error I get in chapter-7 after moving the line out of the “loadview” function

image-2

Chapter 22: Core Data > Object Graphs
A minor correction regarding the terminology of Graph Theory. Vertices are the nodes, Edges are the lines which connect them. As such, the final sentence in the first paragraph which reads:

This collection of model objects is often called an object graph, as the objects can be thought of as nodes and the relationships as vertices in a mathematical graph.

should probably instead read:

This collection of model objects is often called an object graph, as the objects can be thought of as nodes and the relationships as edges in a mathematical graph.

or equivalent.

Chapter 10, page 192, I’m getting a SIGABRT error when replacing

let cell = UITableViewCell(style: .value1, reuseIdentifier: “UITableViewCell”)

with

let cell = tableView.dequeueReusableCell(withIdentifier: “UITableViewCell”, for: indexPath)

The program works fine with the former but will crash with a SIGABRT on line 12 of AppDelegate with the latter

Agreed. It would also be cleaner to set the alpha inside animateLabelTransitions:

    func animateLabelTransitions() {
        // Animate the alpha
        self.questionLabel.alpha = 0
        UIView.animate(withDuration: 0.5, animations: {
            self.questionLabel.alpha = 1
        })
    }
1 Like