For collecting errors found in the 7th Edition.
I believe there is a bug in the code presented for updateTags()
in the Photorama app, page 469. Details are here:
@gc3182 â Good catch! And perfect fix.
Weâll get that fix in for the next printing. Weâll also update the online solutions, along with adding a comment explaining the fix (since the 1st printing obviously wonât have the fix in place).
Small typo inherited from the 6th edition on page 443âs description of the object graph: objects can be thought of as nodes, and the relationships as edges in a mathematical graph (instead of vertices).
My read of the Apple documentation gives a different picture than Figure 13.5. Are you sure Unattached->Suspended and Foreground Inactive<->Suspended (without going through Background) are possible? I also thought there should be an arrow from Background->Unattached in some circumstances.
Chapter 20, page 402:
Create a new Swift file called Photo and declare the Photo class with properties for the photoID, the title, and the remoteURL. Finally, add a designated initializer that sets up the instance.
However, thereâs no designated initializer, neither in the book or the solution
Chapter 18, page 374 (pdf version)
The imageButtons property stores the images.
The images property stores the images
Thanks for calling this out, Pierre.
Iâm using an eBook so no page numbers. But as Pierre said, in the paragraph above Listing 20.16 it instructs us:
Create a new Swift file called
Photo
and declare the Photo class with properties for thephotoID
, thetitle
, and theremoteURL
. Finally, add a designated initializer that sets up the instance.
However, the code in Listing 20.16 has a fourth property for dateTaken
which the text above does not mention:
import Foundation
class Photo {
let title: String
let remoteURL: URL
let photoID: String
let dateTaken: Date
}
And Listing 20.16 does not include the designated initializer which the instructions above tell us to create. Furthermore, as Pierre pointed out, the provided solutions files for this chapter have also omitted the initializer.
Here is the code I wrote for this step in the instructions, which includes an initializer:
import Foundation
class Photo {
let title: String
let remoteURL: URL
let photoID: String
let dateTaken: Date
init(title: String, remoteURL: URL, photoID: String, dateTaken: Date) {
self.title = title
self.remoteURL = remoteURL
self.photoID = photoID
self.dateTaken = dateTaken
}
}
Iâm reading the book, via Safari Online Bookshelf so I donât have exact page numbers.
In Chapter 3 under heading Views & Frames there is a code snippet like the following:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let firstFrame = CGRect(x: 160, y: 240, width: 100, height: 150)
let firstView = UIView(frame: firstFrame)
firstView.backgroundColor = UIColor.blue
view.addSubview(firstView)
}
}
When you try this code you will get an error.
The view object is not able to be referenced this way. I tried this.view
(couldnât remember how Swift refers to the current object) and had to search to find the answer.
The last line should be:
self.view.addSubView(firstView)
self
is not mentioned in the text before this point so it was a bit confusing.
Also, the code download does not include this sample code in it so I couldnât verify what the code actually did to get the ref to the view object.
thanks
UPDATE: This is odd, because now, later, after a successful build I was able to remove the self.
before the view object and the app builds fine. Maybe this is an issue when the project is first created or something?
(I am reading both printed and Kindle versions) I realized that Fahrenheit to Celsius conversion is quite handy so I moved the localized WorldTrotter version of the Chapter 7 app to my iPhone for personal use (I travel overseas sometimes). When running on my iPhone via Xcode debugger the app works in its entirety, so far so good. When launching the app with the lightning cable disconnected (or just by tapping on the app) the app crashes when selecting the âMapâ tab. I have pulled the crash report from Settings â Privacy â Analytics & Improvements â Analytics â âWorldTrotter-2022-01-15âŚâ I have found a quite cryptic error related to some dictionary lookup failing in loadView of TabBar. So I instantiated the MKMapView in code of the MapViewController and the app started to work outside of the Debug session. Hmm⌠Obviously I jumped into the Emulator to see if the same crash can be experienced there, and sure enough the app crashed similarly. Then I moved the tabs to designate the Map a primary selection. Booya! The emulator has displayed a lot less cryptic error: "uncaught exception âNSInvalidUnarchiveOperationExceptionâ, reason: 'Could not instantiate class named MKMapView because no class named MKMapView was found; the class needs to be defined in source code or linked in from a library (ensure the class is part of the correct target)â. Resolution: selected the top project in Project Navigator, selected WordTrotter in targets, selected the BuildPhases tab (to the right of âInfoâ) and added MapKit.frameworks under âLink Binary with Libraries (0 items)â. VoilĂ ! I wonder if we need some mention of this in the 8th chapter on debugging?
Or perhaps instruct the reader to select âMapsâ in Capabilities? ios - Could not instantiate class named MKMapView - Stack Overflow
âŚhaving continued the Localization chapter to the section âNSLocalizedString and strings tablesâ I realized that the authors are under impression that our MapViewController is initialized manually (in code) but for some reason my projectâs MapView contains MKMapView in the Interface Builder (I must have rolled back some code after completing some of the Challenges in prior chapters). If I rolled back the manual configuration of MKMapView in error I apologize for the request above.