By Developers, For Developers

Historical errata for iOS Apps with REST APIs

PDF PgPaper PgTypeDescriptionFixed onComments
13TYPO

“We’ll stick with tods”
was likely meant to be “todos”.

2017-08-01Fixed in the Swift 3 update that's now available.
41ERROR

at the end of the code on page 41 there is a missing closing parenthesis

do {
guard let todo = try JSONSerialization.jsonObject(with: responseData, options: [])
as? [String: Any] else {
print(“error trying to convert data to JSON”)
return
}
// now we have the todo
// let’s just print it to prove we can access it
print(“The todo is: ” + todo.description)

// the todo object is a dictionary
// so we just access the title using the “title” key
// so check for a title and print it if we have one
guard let todoTitle = todo[“title”] as? String else {
print(“Could not get todo title from JSON”)
return
}
print(“The title is: ” + todoTitle)
} catch {
print(“error trying to convert data to JSON”)
return
}
})
^ - this parenthesis is missing and errors are really unintuitive…

2018-07-03Are you referring to the )? If so, check higher up in that function. You should have: \n \nlet task = session.dataTask(with: urlRequest) { \n \nNot \n \nlet task = session.dataTask(with: urlRequest, \ncompletionHandler:
209TYPO

In Xcode 8.3.2 the Behavior section is title Starts instead of Start. (First paragraph after the screenshot on this page."

2018-05-09
9TYPO

“often code written a GitHub user” should be “often code written by a GitHub user”

2018-04-05
11TYPO

In section 1.5, second paragraph, second sentence:

“There’s always a bit of a learning curve when you’re using any with any web service for the first time.”

should maybe be rewritten as:

“There’s always a bit of a learning curve when you’re using any web service for the first time.”

2018-04-05
28TYPO

The last line of the first paragraph as a spelling error = checkind should be checking

2018-04-05
129TYPO

In the paragraph that starts “It’ll get set to true…” There is a typo in the parenthesis “(but fwhen…” fwhen should be when

2018-04-05
148TYPO

In the loadingInitialData() function, the first line:

isLoading = true

should read

self.isLoading = true

2018-07-03That shouldn't be necessary since it's not inside of a closure. Are you seeing an error/warning?
154SUGGEST

In the last paragraph of 12.1, you suggest:

“Try revoking the OAuth access to your GitHub account…”

This should, at a minimum, refer the user to 12.3 or else the app will be in state where it looks broken, because the keychain will have an invalid OAuth token, with no mechanism to refresh it. This may not be an issue in a simulator where you can wipe the state, and start w/ no entries in the keychain, but on a real device, you’re left scratching your head as to why it’s not working.

2018-05-09
89ERROR

“private func parseNextPageFromHeaders” gives an index error in Swift 4 (xCode 9.2). Need to update “substring(with:” to new String slicing.

// let nextURL = item.substring(with: range)
let nextURL = item[range.lowerBound..<range.upperBound]
…
// return nextURL.substring(with: trimmedRange
return String(nextURL[trimmedRange.lowerBound..<trimmedRange.upperBound])

2018-04-05
100ERROR

In Swift 4 (xCode 9.2), “func refresh” needs an explicit “@objc”.

// func refresh(sender: Any) {
@objc func refresh(sender: Any) {

2018-04-05
151ERROR

First part of the responseJSON block uses only 2 guard statements. On pg 139 this block was created with 3 guard statements. On pg 152 it has 3 and pg 153 specifically mentions “the three guard statements that check…”

2018-05-09
9TYPO

Section 2.2.4, paragraph 2.2.4:

—
Do display these three lists of gists, we’ll be able to use a single table view with have a selector so the user can pick which set of gists they want to view.
—

This looks like it has a couple of typos readability issues. I think what’s intended would be something like:

—
*T*o display these three lists of gists, we’ll be able to use a single table view which will have a selector so the user can pick which set of gists they want to view.
—

33TYPO

Paragraph 2:

“So when we give Alamofire.equest()” should be “So when we give Alamofire.request()” (missing ‘r’ on request())

Categories: