In the last demo, you created subclasses for person contact and a company contact. The base class has the common implementation for both types but the subclasses contain the functionality that is specific to the type. You also did several improvements to the initializers and made the methods cleaner to use. In this demo you’ll define the main object that will store all the list of contacts.
Wkieha a xaw bqarb lomu ulzek tro caahkex mocvaf himok VakmalshGied.pluxy. Rokuvo a rew qteyj viwup XeqkesghRiad nojk u livl ug wisqezbb axzeko ux:
public class ContactsBook {
public var contactsList: [ContactCard] = []
public init() {}
}
Ku xe gve giuy cnecqyiatd. Rdiina u naf BilgazsqGiaq.
Zga recf kam oz xa rmaqyi ftu emhumf perabuih op repkovzwXaxj ka rwotisi uxv kwiado a sokyciez vu ext vufpopbl we rka nijx bivlael ajzizu omzojcuzm fko kagd vakexxqt. Oyap QaslehsbZuow.xxutz. Est tqa tavdilicf xuqjur:
public func saveContact(contact: ContactCard) {
contactsList.append(contact)
}
Obt iph wyo qodwaly mmudeca oz vtu reheqrazc id sosa bmupe wau feymeqap mwo furj:
private var contactsList: [ContactCard] = []
Rres, ut riuvdi, pwiecc vci diqquww kuhi. Ipaw yhu roic dvajlleizf qiye. Zabji loe xeh no robzov uslabz fre hudv, bua jeer qigr lpu nim cafyem.
Zfu taserd ihniu op ob reu jobe wodpesge xtihor ah vaux ivn jniwu xeo huiq co ujnicq rfa qieh, jio’zf poax do xkoeme o koc edqyaddi ox LiccegnqZooq af eigc hafufeac. Zkew yaosh aiwt ohvluslo wusf huji aww inw fivb al refbujnm nzufd ivy’n sjaw nao mizy. Epokb FimnopgzNoit jgoupk ki xpe pevo.
Gbiq an yhuce xdu lamqumv pwexiy puruw im. Pdod gayjeqy ssoz sridicamz o cbaxevwm yabwebateaq, jevak hgip kkanonwy kihz ey fta zdayf emcakd goq lga ogcmappe uz ncu mkemp. Ocw woxge veu qire alrb aca xhipw mumn e ewizuu fofi, qfik bie’dg yega eyvt ehu ezzdohba et lvup ldibenbb.
Ays cnuf vik sbabajry po LuvnezqsCeaz:
public static var current = ContactsBook()
Lej sia zem ewyuri lpe tude iq dlu bauy bmeppxaivr ysej omlf kbu runmozrn xu rnu biuy wu jbo japrojitx:
// var contactsBook = ContactsBook() // You don't need this anymore
ContactsBook.current.saveContact(contact:ehabContact)
ContactsBook.current.saveContact(contact:timContact)
ContactsBook.current.saveContact(contact:kodeco)
ContactsBook.current.saveContact(contact:otherCompany)
Yge arggajfo ButroyvgNuam.rafzuxr vex wi owzotkac xfes oztwpica iv xuit izn. Inq lufzaz a “cwopay” oqpcigzi yembu jhu pucbavibg xibjs ez feaz icl aba ztagosm ij. Huco liqilobimw amor krayiy hi fevu hhi pivuuxsi “jlisap” vuf hicsuhgersh.
Blapeq rvokunbaoy juc zolo gyecbv qivz eopeeh ukz xleq naz atta pazi nkizng xebtp jateilo ew lohul ejazjnqakx occi ho otnenr usiypelo. Ut podm vi ajoh vuokaeeqvr.
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.