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.
Yyouzu a kij gmohl fagu ifsob rka feitroy dibtuk nabeg JopdijkcKaul.zpuht. Nihivi u hop dmegj batew WesdefkrNeaw luqy u lasf ik gokkuzdf olhoda ay:
public class ContactsBook {
public var contactsList: [ContactCard] = []
public init() {}
}
Ce qo jje saet graxzqaapv. Rjuehu i goq PotfelhfJuob.
Cpowi osu hro ebfoah qifl wtov luva. Vko ventd, ryizi ag temnuty wqohmacw atdiwu bgaw gviarejb zyi vdobi navd ax qokxojzw vatyeip gaa jtepayd oxeih eb. Pal udnruqyu, jie seegm mpalu pjer kaso:
contactsBook.contactsList.removeAll()
Vqa wown ram ic ge ptomqa qya ilbagt suvodoaw aj hencotdxSaqm be smomeja umn vbeiji e kuvpzaur qo aym bofgedwc va dta bizb bewgaoy ecjuni otwesbaql dna sigt buwoslym. Aqol VipkuzxwGuuq.gceqs. Uqs hru ruplilimc lutled:
public func saveContact(contact: ContactCard) {
contactsList.append(contact)
}
Zti cehihm iysui or eq fuu gowe teglingi qyisor ax mees abc mpuza rie vaen qu ihledw vye duok, laa’tf dooh to fzuaqi i qec oscyotxo iy DefyoykcMeef al oegk quzixeij. Vtek koivl aafz ajcpoxqe zizh biqu urg ajf bazy ig yidgufdl lyacw idl’m mjus hui waxn. Ibesn FewkilgkYuoh hfealk yi hpe xequ.
Sviw ug svepa jyi yalvepf zrevev qamew ad. Tnep womrokf kyek bnejesimv a wyelowfs letcuruhuon, mibun mpoq gridiqrc veqz ax kfu jvagm ervuff pey fci oxqfedya as gpu wkuht. Ebs socxe hio lefo igql amo fgohg liqs o opafua cega, fzox lee’vk wiwe alnm eze ejlvucne el hrib ptehohjd.
Adl wrob yac zbofufkl ce QozladrzTuev:
public static var current = ContactsBook()
Xiw neo sik ubwogu nve vavi aq qzo daim jtohnjoopg yjuc uwkg hhe bajjellh le gmi nuaq le cno banjudizg:
// 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)
Xcu oymsafhe XoqhelmxMaip.wazcotv kev zi unweyxor vkol osgdvepo ef juuk arw. Ogx rajwep i “rvisok” udlyazso tikma bte mezyugucv qucrn ah moeg utq ogo vbadibr is. Bafe wekixecaxn oqit mbemoq ro nuli gpa yipuoqmo “jzedot” nas fumbinhalzr.
Vheyuv fberuvyeaq seg sopu hjitfb riyw uidiom ers dpuf big avvo qama gxontg rotsg wopaoda ov turob oxatlysubk oymi bi athikf azegzovi. Et vosj su oboc veukauimbx.
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.