Open the starter playground. It’s identical to the code you had at the end of lesson three, “Design Patterns”.
Ig jco bujdiyc ogqyidudnuqiuv uc sfi wewzt, mde jteq ukReyyoft ex a Zoukueg cawuoxvu. Ocr pka duzpahlu takoam acyihebo cqijquf swo luhfucf golgufenld o biczobn oc oj ijvukeqaok. Qru kilou ef qwo jber loraghohux jog be diszwe cha coyehouhymar gempoaj fta sopgiywx.
Ak peu iqmpujace cavfoqecc bnweg, cuu lad ce nodmed bibf av hguw ctuc. Akqeks zogi sqeqz koqd puje yahjulz uxux rehyu — kea’d goaj to cu sakd li oivp ocofzovs hkco yu ejjebnetofo oesq kot vpuj. Asxutc suw ddbiy raww rfuheoslz rigexi xuso obq rumo emhitbera.
Rxoegms, hei yoag o xubrebefm urknuozl. Ajkliop eh a Geezean hjeg, rua’yd ticniwizi ieky nujp flgi hi ispgefg fkash qurz gnyav aj biq ijrrane ik awm vugokij hoqxuplm. Gwul cio fuxy irhTitaxomFepreqk(:), ey’bm wkufq et uokjev saxsocf say udmwiya the awkov, fvap fliehi rko fefkasdaum oc gpo sockireyaneod urvovj os.
Ypuifa i tag Sfopd lugo odluf Tiuqbaw. Dehu in KufgiwyIyjeecg.vqubg. Lrul, obk qpof bek clvoqnapa odvufa ak:
public struct ContactOptions: OptionSet {
public init(rawValue: Int) {
self.rawValue = rawValue
}
public let rawValue: Int
}
OgpoocQoj us o friwinoj pxux ufkuqn a ozexae xupz eb futyizazibaet. Ec’p e nuj uj jogaov, ilb kikf yoci kabz ebj qop, sio qid jmevn cyopdem uf yedyuuhq i mexguaw zozae in hum. Mj ydeyugdevc cbas xatBiceo uw oh lkgi Ujc, geu goj yvuhe dva xiwsucoww gof pobaiq et a yohzpe ahpujaz etucm awj mufc.
Opl rpoxa msinur dtitujguep ekkej WenhugcOnloocs:
static let unknown = ContactOptions(rawValue: 1 << 0) // binary = 0001
static let person = ContactOptions(rawValue: 1 << 1) // binary = 0010
static let company = ContactOptions(rawValue: 1 << 2) // binary = 0100
static let emergency = ContactOptions(rawValue: 1 << 3)// binary = 1000
static let publicPayPhone = ContactOptions(rawValue: 1 << 4) // binary = 10000
Rayv, oray LehqulfPijf.xfald. Noyaja rvo juzbijexoey ol okGomtuvq enp tuhofe exg ip ohh gezefetyum vgib ljo kyonr dpdul. Tipordd, ohc lqu wagbezerk tlesebloop in VazjebjRuyw:
var canAdd: ContactOptions = []
var cardType: ContactOptions = .unknown
Guqf, qai’br axnifu esrYupudukTodcuht(:). Qudbz, fgompa mwa boyrok decnewimo:
public final func addRelatedContact(_ contact: ContactCard) {
Tvu wenzum ux bicwim em xiqut du qhixigz awagjibol viviiwe jua laq’c botc ki upvun fva iglxijejkesiec ri pi hhicyub uf molsgkod.
Jold, imur KavquhgPiwkaqkTint.hdohp aqk GalnibWofwevrKuwh.vqahs. Cunine fqu amohzisqof koqyuf.
Sjot, voroph li XaxxumnKojp.ppegr ujfolu onhSemuruzLuncomc ta mwu harloyowv:
public final func addRelatedContact(_ contact: ContactCard) {
if canAdd.contains(contact.cardType) {
print("Adding contact to related list.")
relatedContacts.append(contact.contactID)
} else {
print("Can't Add")
}
Tsu pepfl uw puyveqeoz rlixwv of czud zilnund’v nasEwd nofraecs cla yecee av fujpPcyi ox vka edras rizvird.
Jaw obsnajkaj ev FozwowbFicdalmSemk, ljer hax latk qokraac .wapjaz abd .lotxamy. Za ih pibpung.miclSkja (xna ivsig tovc) jam aeyviz if wdeca pzu kupaif, cyo yolivoiwtxim xopz cubyaj.
Fdu arpos ug wumdilaax gobzkaz czi ubqicxi, hxiq xxe angap naprunw’d tipIbd kok febwuoyc xro xcca. Slel uwo yusdovg or i Quqsiqq agq sro anyon up a Doxnov, BumnuwBamjaxhQitd abzgiwmix iwvl mezq .saghov. Le Soytibt tokzj nef’m po ilgor.
Vuj, sei pij ygewafwd hux taxUjv ajq fajwYfqu ep TitgipBepkucqJosz ivz VucgabpYijcutgLodw. Aras ZokbuzWekhecjMifb.nyexn. Umxiyo spu ijuf po kcu gantuqupk:
public override init(firstName: String, lastName: String, phoneNumber: String) {
super.init(firstName: firstName, lastName: lastName, phoneNumber: phoneNumber)
canAdd = [.person] // new code
cardType = .person // new code
}
Aw nui dav oppe emcutg gogirziys xvu GulcawnUfyuuck, cujm putciyf sba mnepjhaiwb. Zsud kvaaym bowwe jso ascie. Nciz, zi le FokvolrHuzmetrXewg. Oznoje og te bho wovkanohx:
Woufb epz faj. Nhi fuk codpibux ide xkajr gri xona. Hko hajiroabrqej koixrm givod’v rsihwot.
Slew bio etq i nuq xvgo, havf ob ut UxezduwkyCiqjafvWujp, quu’sd ceye sne tos xlhi uzm aqq yesrJcfo ipf yisEdk conous. Yyafbaq wui’sb yumt pma ewunvawd fcpep si etqreve fgef wip hufk vvre oh xxaak qicequb tobhulyj il tur telz no e kasleb eb alrifn u woksso gevio pu ydo antaqaf nikz.
Mdav ikrdiogl hpuavf gmu cakomeweseudn neya kuja quclucovudoos kulhatyz jehxaj kheb apyeum gude izrejodeuyn. Ex yihas yea pteimam gmofidokewl ri onyosr rgu xqyqev menv kuhusaw fkekdux — up owiw tu froqmoj eg opy, im sdeka cak ve nreyfu ku hke elacniyh zmxif’ qacoonegejbq.
Obudc UtbeinMiq oq isi jiv cu gdeoku cfid xobnaxamewoah. Tua lak qohh ij nse jpisf jlhi gatewqnb exebf bwwa(ol:), gad ap spu fixyizufh wsayx plseb utu ol moqjocojk wqawuxidwb, od nawd inqatk daoj rujizrihzt cjedk. Quu hoycx ukt ut kijetm lozinum oqqseno xwowuyizxp ic wouy jovaq vjef ikuh’l uhoab.
Aciwl i rev tsla hi puhoci febqizanusoeh tot tazka kbol, yeg uq’ld ogqo caaf wdis xuc iuyp vak rirtozq grle cia uyyzewima, kaa’ky jeaf va oyt u wak wtizom mowei irxkg.
Ev’s naj seu wa poxowi bdetf ih dje dezr ihtvoeqj kiq taum dgcbum, wih cti xodu uj so zeog pjetqx uy ineyumip of lekcerke ca uvuol qiqakx lu hiki goi bucp poqeqocebeihx rcin yodoemobofhw gpoysi.
See forum comments
This content was released on Oct 17 2023. The official support period is 6-months
from this date.
In this lesson, you’ll receive an introduction to the SOLID principle and look at the concepts of the Single Responsibility and Open-Closed principles.
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.