Errata - iOS Programming (7th Edition)

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 the photoID, the title, and the remoteURL. 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
    }
}