November 2018
Intermediate to advanced
404 pages
10h 16m
English
The first step is to create a new final class, called JournalEntry, that implements the Codable protocol. There are three fields, id, title, and content, in this model. As shown in the following code, all fields are optional because there is a chance that a field may miss from an JournalEntry object when you retrieve the object from the cloud application:
final class JournalEntry: Codable { let id: Int? var title: String? var content: String? public init(title: String?, content: String?) { self.id = nil self.title = title self.content = content }}
The initializer only accepts title and content parameters. Since the value of the id field is automatically generated by the database-handling process, you can set an instance's ...
Read now
Unlock full access