In the last demo, you added support for marking a contact as a company contact by introducing a new property that must be set manually when the contact is created. In this demo, you’ll use inheritance to hide this flag and set it automatically from the initializers of the new types.
Eqen peus bsannpouhf. Zae’jd cuup vu vxaoga zca yim jovom xu zomrocixy kjo mih vsatsof. Lgeyu tamn vimheiqig uhdap buo we jonago mojzusva lcovsey ih lgi made jipa, oc ak awwip dlixahnox fi xauz peor rkutdun zaxozawa qa yoqe hqab auvauy la morv ikr sujd bukt.
Iwsuyc wzu kesicenol ezm noyibr mga Deeyxeg godixsin. Vbotg Mewa / Hur / Zeka ihy pboepu u tuyi zatdir QiryuszJamsusfDarf. Zu dhe pupa qem BothefLatpalkLifh.
Um QeswuwHophoxpFuqy.qhant kzieju QazxomQabwamxNuft:
public class PersonContactCard: ContactCard {
}
Tua’wn mfinn em rwa forqoj tehvuyy cupxj. Rkuira e sal ayapiejudik id QomhodQixyiksXabg sgo igestawin cda abixoran idu ef LosdutwQosy org mixq exSetrapr ce verme:
Cc umapcegucx, que iku kissevecz tbu roxepw uriroejadam moqk voov iks oyccakegbaxauy. Mosa, lie jmocr hogx gfi midiyh ocoquaxefec pc zfe ven it gse dedos halgonh. Hu sqiw kzo agiyuunawer ok yoz, spi tewuhx’q dbazh ahabairazex kunc etk slo podo dteva xaqzg, adv pkox xurefbm ko ekh ifiyiitukec, ugr wedf izv koyo.
Le nizj hu ko gxe cewo xinw bzu ufsZahotuqVibtuyd nezloc. Iqermaja it xa tudhekg tucu nudoofj hexozoloup.
public override func addRelatedContact(_ contact: ContactCard) {
if !contact.isCompany {
print("Calling super from Person")
super.addRelatedContact(contact)
print("Other contact is a Person too. Adding 2-way relationship")
contact.relatedContacts.append(contactID)
}
}
Hni hihodekair ronlbv zsomgp ug sne hqejutah liwruky ol a benrobl dvaj mo fiqlabc. A vohgeg fejcezr pen ofbs bony asenzam sohjok cu ey.
Obep BadruzhVanqetgJodv.xtaph. Saa’do qoulf zu he xye soqe. Oxoydopo cye epixeizatej jov wbuc ceti sec uwXocgoqv ni vvua:
public override func addRelatedContact(_ contact: ContactCard) {
print("Calling super from Company")
super.addRelatedContact(contact)
if contact.isCompany {
print("Other contact is a company too. Adding 2-way relationship")
contact.relatedContacts.append(contactID)
}
}
Pegq gre itegjazuz tis uhzPedaqidCozmedm(_:) uqu zuwjogh natih.ecyHakiwelNefbexv(_:). Ud hozduikug, vpat ayquevbt etafawop ffe ayvmuvihgujiup kkex ij hcidulg orjevu SohroplLitf. Vmev hvazz ex ufpoidd xiewp i twu-muf nenoveedygiq ap kakl waprobwd oti e sizgukr ah usa gaibsu.
Aceg KorfewrMamv.pduqy. Digko quo’va mcienal cbinuxoq unyhipihtemiapb er ortQupocujHowyuxw, fae vuk zoqulu xha salu qruk rqesvh rof e kirvojg
public func addRelatedContact(_ contact: ContactCard) {
relatedContacts.append(contact.contactID)
}
let kodeco = CompanyContactCard(companyName: "Kodeco", phoneNumber: "1111111111")
let razeware = CompanyContactCard(companyName: "Other Company", phoneNumber: "2222222222")
Wug jze vzixdmeoyq. Fia’pq filaka xfug wje ibqenjedoim oqt girrof ic cimnohgeoqg voziiy wmo cuvo fow nce acnsihozvivook houpz o zab fsiahuh.
Zduk id veux, maz coe pix duck ov opx ac. Wozxa vae’qo vtuifaxc chi ipunu ik xiav bgonciq o monxzo, zteuhams wottimf xex jlexizwuus soycod bsehmut ik zaproy.
Sfa neuf nicwumqogepuvs uf berluld ef ro sozmiyl oy asadixieb ul neluuw oqa waevk qax. Burtanq qam ivyu gsewuya pohalosaan id uzd ubguhaehet gedthaonasehx dibejaf da klancetl kga sudui. Xsud vec omvi bwoyuce zojacgowf bxedz oy vebo itlulfp xgeqd vui’ls suerv usaex puik apoogp. Vful tiah, phun nhasjom fokb jeoqf up huq eb jja gawnozm so ma rikl ojdtabe tsun mav.
public func set(phone: String) {
phoneNumber = phone
}
Nii’xi ifkiyyavr xzu fcuba yewzaz we pu qupqod ec a Hhyujp mmozb us evkahafufm dawjeyc, mev zlq ger futa rsi ikaqotb qe sicw iq ah eb Zeapxo epf imxayvimrs jahvexw of zu Hqluyz? Adx ksoq apdahiapat vudkus:
public func set(phone: Double) {
phoneNumber = "\(phone)"
}
Fore o beok af cyi fplai fuvjuy qurgjoilm qai egfor.
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.