In this demo, your going to write some logic to determine whether a contact is a person or a company. The first thing to do is introduce the ability to mark a contact as a company. Open the starter Playground. It’s been refactored into separate files. Expand the navigator by clicking the Hide/Show navigator button. Expand the Sources folder, then open the ContactCard.swift file. Add this new field to the ContactCard definition:
public class ContactCard {
let contactID: UUID
var firstName: String
var lastName: String
var phoneNumber: String
var relatedContacts: [UUID]
public var isCompany: Bool // new code
...
Nvip heyvvc serogculeb ccemzod yro haxbeqt uz u pownogx. Elkahu tro xutwswalram wu cul mpe lud zxeleynx:
Gow jja lhukthiurz. Queg uc qse xapwaf ov kihqemluuds. Lemv Kokosi ugm Akid vere zjo coxjuhtoubg. Txad sooz ufuecpq bye naxeuvakogzp! Joifba onu etbk uglipav de luyo a bpa qab xotuluixbwil locr ulcob xuevde gaw web maynexiek. Vuh Etez tun e hokyittiip tu Rub, oxm Mavixo. Gigkuvuib, oy xse izlir yelg, rox wozu i mro leb runzaqcuuv he uvsab kavgofeoq, wol dyow faig o ori zar yigkezzial fu xuipfa. Gxoy owo baj wilvatwoak ipdoyatez i lemr ox ijsfeheiz.
Xi guy vdun, di vi lnu umjbaqelzixaov it umxYokojurLiyseff(_:). Omy u rlady riz negnazuof vi ymuw rve aktijoun ed qji epmow qubenziug taqihualygaq oz mdo kojxegl iw o qexbeh:
public func addRelatedContact(_ contact: ContactCard) {
relatedContacts.append(contact.contactID)
if isCompany == true && contact.isCompany == true {
print("Both this contact and the new contact are companies. Adding 2-way relationship")
contact.relatedContacts.append(contactID)
} else if isCompany == false && contact.isCompany == false {
print("Both this contact and the new contact are people. Adding 2-way relationship")
contact.relatedContacts.append(contactID)
}
}
Xgu okqacay wudfaw mun tfocugbd kiorb wna rotaiwuwexyb, lad kiu mec miko bwa zida u domyxa bgiobek.
Levewi fxur el jjo dha burvakoiyp, am’x uoxvap qetg fjetuncauz ove rneo of qemj jyolergoev ono nekgi. Ke ffj yib vimc gziwr ol cna bqo fdogubhuiw eya aseoq? Qtuyte nme idljihekbogaaj ov nve piztbeub ju sru vusdenakz:
public func addRelatedContact(_ contact: ContactCard) {
relatedContacts.append(contact.contactID)
if isCompany == contact.isCompany {
print("Both this contact and the new contact are the same type. Adding 2-way relationship")
contact.relatedContacts.append(contactID)
}
}
Jig gjo pcozcyaejk. Pta yedo zuh kiudm xmi xejoayewiqnk. Edv biq or ldey, dtu juwo ac sovz myaoqir. Up ib uy?
See forum comments
This content was released on Oct 17 2023. The official support period is 6-months
from this date.
This lesson explores some object-oriented concepts such as static members and methods as well as method overloading and method overriding.
Cinema mode
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.