Instruction 3

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Heads up... You’re accessing parts of this content for free, with some sections shown as scrambled text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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
Download course materials from Github
Previous: Demo 2 Next: Demo 3