Errata

Learning Swift

Errata for Learning Swift

Submit your own errata for this product.

The errata list is a list of errors and their corrections that were found after the product was released.

The following errata were submitted by our customers and have not yet been approved or disproved by the author or editor. They solely represent the opinion of the customer.

Color Key: Serious technical mistake Minor technical mistake Language or formatting error Typo Question Note Update

Version Location Description Submitted by Date submitted
Mobi Page location 919
The Basics of Swift->Control Flow->Loops->4th paragraph

Can't give a page number; Kindle app on macOS doesn't show page numbers (only locations).

half-closed operator is listed backward in the text description (but correct in the code sample):

"Called the half-range operator, <.. means"

Should be ..< instead of <..

Bacil Donovan Warren  Jan 04, 2017 

The Notes app will not compile for the following two reasons:

The enum NoteDocumentFileNames has no member 'locationAttachment' and fails to compile this piece of code

if let oldLocationFileWrapper = self.documentFileWrapper
.fileWrappers?[NoteDocumentFileNames.locationAttachment.rawValue] {
self.documentFileWrapper.removeFileWrapper(oldLocationFileWrapper)
}

Secondly, in the next paragraph (line 78), we have
i
f let location = self.location {

let locationDictionary = ["lat":location.latitude, "long": location.longitude]
if let locationData = try? JSONSerialization.data(withJSONObject: locationDictionary,options: []) {
// save the location data into a file
self.documentFileWrapper.addRegularFile(withContents: locationData, preferredFilename: NoteDocumentFileNames.locationAttachment.rawValue)
}

}

There is no location member in the type 'Document'

Earl Quinones  Mar 12, 2017 
Web Site

Actually, not in the book, but on the O'Reilly web site for the book:

Swift 2 basics: Learn Swift’s basic building blocks and features for object-oriented development

Ought to say Swift 3, not Swift 2

Michael L. Connolly  Aug 22, 2017 
PDF Page 22
1st paragraph

...which is the third tab from the right at the top of the utilities pane. I am using Xcode 8.2.1 and it is the "fourth tab" from the right. (file, quick help, identity, attributes)

Rick Jepson  Jan 05, 2017 
PDF Page 23
bottom

page 23 bottom: UIButton should be UIButton!

David Head  Jan 06, 2017 
PDF Page 24
Code Sample 4.

Using Xcode 8.2.1 some case changes but especially "self.presentViewController" has been renamed "selfpresent". The code becomes:
var alert = UIAlertController(title: "Hello!", message: "Hello, world!", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "Close", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
self.helloButton.setTitle("Test!", for: UIControlState.normal)

compiler warning on var at beginning suggesting as it is unchanged, unmutated I should use "let" instead of "var"

Rick Jepson  Jan 05, 2017 
PDF Page 24
top

page 24 top (sender: Any) instead of (Sender:AnyObject)

David Head  Jan 06, 2017 
PDF Page 24
top (Step 4)

page 24, step 4 (the new code). Every line has a problem. E,g, first line .Alert should be .alert. Same for second line (.default, not .Default). In the third line, the compiler seems to be saying that the name of the presentViewController method has been changed (not sure though).

David Head  Jan 06, 2017 
Printed Page 25
Item 4. showAlert method

Due to a language update, in the last line of code in the showAlert method, change parameter label "forState" to "for", as shown in the following:

self.helloButton.setTitle("Test!", for: UIControlState.normal)

Anonymous  May 04, 2017 
PDF Page 32
2nd bullet point

In section "“Swift 2 Versus Swift 3”

2nd bullet point:

“You can use +for in+, while loops or stride to replace their functionality.”

The String "+for in+" seems markup mistake. I think that author intended to change type face for this string.

Anonymous  Jan 25, 2017 
PDF Page 46
Final paragraph

Text says:

"In addition to appending to the end of the array, you can also insert objects at any point in the array. Swift arrays start at index 0, making this code identical to using append:

myArray.insert(5, at: 0) // = [5,1,2,3,4]"


Isn't inserting at 0 the OPPOSITE to append, not identical to it?

Anonymous  Jan 07, 2017 
ePub Page 63 - 78

The swift code in the book is not up to date with xcode 8.2 remaining is the main problem.

Herman C Vermeulen  Jan 11, 2017 
PDF Page 68
Sample code

A global function named `sqrt` is maybe replicated.
So, We need to use `squareRoot()` method to calculate square root.

before:
width = sqrt(newValue)
height = sqrt(newValue)


after:
width = newValue.squareRoot()
height = newValue.squareRoot()

Anonymous  Feb 25, 2017 
ePub Page 70
4. In the ShowAlert...

var alert - Xcode 8 gives warning, suggesting var should be let as it is not mutated
UIAlertControllerStyle.Alert - should be alert
UIAlertActionStyle.Default - should be default
method signatures for presentViewController() and setTitle() changed significantly

Kevin G O'Mara  Jan 02, 2017 
70
Chapter 4

Raw/Uneditied version, has no page numbers yet. Chapter 4 examples show Xcode version 7.0

There are some significant changes to Xcode 7.0 and the current version of Xcode (8.3) that is out as of the publish date.

Unable to complete this chapter due to serious technical issues.

Note from the Author or Editor:
Hello! Thanks for this report. The screenshots do show an older version of Xcode, but the steps are 100% correct for the current version of Xcode, and the UI in those screenshots has not changed between Xcode 7.x and Xcode 8.x. We'll see what we can do about updating the screenshots in the eBook and Safari versions. Thanks again!

Ken Williams  Apr 04, 2017 
ePub Page 74
TIP sidebar

I do not list as an "error" since I am a Swift beginner. I tested the

var name = "Dan"
var copyName = name;

if name as AnyObject === name2 as AnyObject {
print("The addresses are equal")
}
else {
print("Not the same")
}

I think this is because "===" only works for classes?
If I do with a made up Class instead of string, it behaves as you expect and describe.

Dan Delgado  Dec 16, 2016 
ePub Page 81
Last paragraph

You probably want to use:
myArray.insert(5, at: myArray.count)


“In addition to appending to the end of the array, you can also insert objects at any point in the array. Swift arrays start at index 0, making this code identical to using append:
myArray.insert(5, at: 0)
// = [5,1,2,3,4]”

Excerpt From: Paris Buttfield-Addison, Jon Manning, Tim Nugent. “Learning Swift 3.” O'Reilly Media, Inc., 2016-12-05. iBooks.
This material may be protected by copyright.

Dan Delgado  Dec 17, 2016 
Printed Page 86
in func withdraw

The comment describing the the first block of code in func withdraw(amount: Float) should be corrected from

// Ensure we're trying to deposit a non-negative amount

to

// Ensure we're trying to withdraw a non-negative amount

Anonymous  May 04, 2017 
Printed Page 103
Figure 4-5 and last line of text on the page

The check box labelled "Use Storyboards" has been removed in XCode 8.3 and the Cocoa Application template used to develop the Mac OS application employs storyboards. Perhaps stating the obvious, this completely obliterates the UI development discussion later in the chapter.

Searching around the web, modifying the storyboard setup to use nib files is anything but straightforward (for me as a Swift/XCode newbie anyway).

It would be great if the authors would post steps that will allow one to use nib files instead of storyboards. Many thanks in advance.

Anonymous  May 06, 2017 
Printed Page 103
Figure 4-5 and last line of text on the page

Until the authors address the inability in XCode 8.3 to use nib files, the simplest workaround I've found is to download an earlier version of XCode from the Apple Developer site. Xcode 8.2.1 will work.

Go to https://developer.apple.com/download/ and sign in
Click on "See more downloads" near the bottom of the page
Enter "Xcode" in the search field
Click on whatever version of Xcode you want to download (choose 8.2.1 or earlier)

Anonymous  May 16, 2017 
Printed Page 114
Code snippets at bottom of page

Replace "NSData" with "Data" (2 instances)

Anonymous  May 05, 2017 
ePub Page 118
Declaration of privateSetterProperty

Minor consistency issue. You refer to the access as fileprivate in paragraph and declare as private in example. Not wrong, but figure sticking to one would less (momentary at best) confusing.

Dan Delgado  Dec 19, 2016 
ePub Page 118
Last section starting with Bold

In the current epub version as seen on a 9.7" iPad Pro, the example operator+ overloading example is on page 118.

The warning to NOT do this is on the top of the following page. A "go along as you go" reader may be a bit discommoded. I am not familiar with page setting. If it is possible to make a paragraph or text box be "sticky" with a preceding paragraph - that would probably help.

Minor thing, it just made me grin slightly at the posibility.

Dan Delgado  Dec 19, 2016 
ePub Page 127
Between 2nd & 3rd paragraph

Not sure if it's an oversight or you just haven't written that part yet. It appears contents of Package.swift is not included.

Dan Delgado  Dec 20, 2016 
ePub Page 160
1st bullet

I believe you meant "is clear and" in the following sentence:

Using it like anArray.remove(at: 2) is clear an unambiguous, …

Kevin G O'Mara  Jan 02, 2017 
ePub Page 190
Last paragraph

The narrative reads “declaring that its setter is fileprivate”, but the code uses “private”

Kevin G O'Mara  Jan 02, 2017 
ePub Page 191
1st code example

Suggestion - don’t use a code example that compels you to provide a WARNING not to use it. The Vector2D example is sufficient.

Kevin G O'Mara  Jan 02, 2017 
ePub Page 205
2nd paragraph

capitalization of WARNING: YOu

Kevin G O'Mara  Jan 02, 2017 
ePub Page 206
main.swift code example missing

Both code examples are missing - Package.swift and main.swift

Kevin G O'Mara  Jan 02, 2017 
Printed, Mobi Page 2389
Figure 4-5

2389 is the "Location" in Kindle

I'm on Xcode 8.3.2 which is the latest as of the release date of the book (printed version which I have also).

All applications now have to use storyboards, so the book is essentially unusable for this section on release. This means the whole sections in the next 3 chapters on building the UI won't work - the authors need to release instructions on how to bridge the gap here.

I'm trying to work out the bindings to bridge it but struggling to work it out.

Al

Al Fraser  May 07, 2017 
Printed, ePub Page 2389
Figure 4-5 and last line of text on the page

Until the authors address the inability in XCode 8.3 to use nib files, the simplest workaround I've found is to download an earlier version of XCode from the Apple Developer site. Xcode 8.2.1 will work.

Go to https://developer.apple.com/download/
Sign in
Click on "See more downloads" near the bottom of the page
Enter "Xcode" in the search field
Click on whatever version of Xcode you want to download (choose 8.2.1 or earlier)

Anonymous  May 16, 2017