In the last demo, you created a contact card type using only Composition. The type is composed of the information of the card and also other contacts. However, this approach doesn’t make much sense.
Your approach has two main issues:
The contacts database in your app is the main array of contacts plus the contacts inside each contact’s relatedContacts.
By deleting one contact, you’ll also completely delete all the related contacts from your database.
A simpler way to approach this is to use Aggregation and list all the contacts in an array. Contacts can have a link to other existing entries to create the relationship instead of containing the relative contact.
This means that each contact is composed of three string values and an aggregation of other contacts to form the relativeContacts.
You need to specify a way to link contacts to each other instead of having one contain another. This is similar to how you can open a file from different locations without duplicating the file itself using shortcuts (on Windows) or aliases (on macOS).
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.