December 2018
Intermediate to advanced
414 pages
10h 19m
English
If you're using value types, you will not find yourself needing to implement the prototype pattern, as value types implement copy-on-write.
Let's use our Article object from the previous example again, but this time as a class, so we don't benefit from the copy-on-write given by the value types:
class Article { private(set) var id: String let title: String let message: String let author: String let date: Date var views: Int init(id: String, title: String, message: String, author: String, date: Date, views: Int) { self.id = id self.title = title self.message = message self.author = author self.date = date self.views = views }}
Now we have Article following reference-type semantics, and we needed to add a constructor. ...
Read now
Unlock full access