April 2020
Intermediate to advanced
528 pages
15h 40m
English
Next, you will create a Photo class to represent each photo that is returned from the web service request. The relevant pieces of information that you will need for this application are the id, the title, the url_z, and the datetaken.
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.
Listing 20.16 Creating the Photo class (Photo.swift)
import Foundation
class Photo {
let title: String
let remoteURL: URL
let photoID: String
let dateTaken: Date
}
You will use this class shortly, once you are parsing the JSON data.
Read now
Unlock full access