In the last demo, you created two new types representing a company contact and a person contact where both inherited from the base type for contact. You created overrides for initializer to apply the correct configuration for each and overrides for addRelatedContact(_:) so each can have its own logic and validations for adding related contacts.
You also created setters for the properties in the contact card. You used method overloading by creating setters that have the same method name only different number of parameters, or same number but different types.
The next and last piece of requirement for this lesson is to create the contact book object. So far all your contacts are created in the air and not stored anywhere. The app needs to have the contacts stored together somewhere and have some class responsible for saving the contacts in a file and loading from that file when the application starts.
For simplicity, you won’t store them in a file. An array is just fine.
See forum comments
This content was released on Oct 17 2023. The official support period is 6-months
from this date.
Download course materials from Github
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.