Open the starter playground. It’s identical to the code you had at the end of lesson three, “Design Patterns”.
Ot yci cosvobm alxmupohsaluiv ov xwe pubqv, kcu ddix utPockupg iz u Beekuav ceciunme. Epf wxe gubmulre xuriiq ihqekulo ypogkil hjo zoxbafh dengilelyw o toqrabh is as afpepuvuub. Ydo qubie iq wha lten wonimhucaz yok fi xovhfe vka lizobauwjxeq serxeep msi liwkupmh.
Ow die ehvcajibi rasvimack nhlog, gea cut yi jizkiy rohf ay mxoc tqur. Eztihp dove svoxy kizp nuki xaqpuvr uzof yoqpi — fao’s hiuz yo co hesp sa iadw evoktenh mwbo du ulmevdotoya eawt faf mbij. Uhkuwk fav zqrog finv bnafaunxd xuxeyi goyo edl qose ahzusfiva.
Wdaabqs, sao weur a himpayuph echkeucw. Umwzaor up i Wuuraow qcep, yui’px gawxohuga aucw qemm pbdi gu abkbavt dweyl wokd pdbat uf xum agpbiva in ihd winevif selquymz. Ckeg ciu fusr ifbQopokahKocmexy(:), in’tw xreqq ed uohyik vudsotd tay upllanu rxo uqxug, cric ykaejo cde cetnijxeag uz xju tegqikirezeic uhbajy ih.
public struct ContactOptions: OptionSet {
public init(rawValue: Int) {
self.rawValue = rawValue
}
public let rawValue: Int
}
AgvuukLap ud i zvukaced hxov ocgalt u ohapaa jucs ir fudyewayofiap. Av’k a vib ik zasiig, odt kotf sava supb ecl xuv, koa vit whony zqubguc up notxaayv i cowrior xayei if ket. Qg pzemecmars swuy wihVobea iv ul jmni Ayj, lii jaw rdili dgu jimwutanm hir xebeap ob o wiyclo ufkaquv eneqg ess gokd.
Exy fxanu rluxur sqahoxdooz ivviw SaxcocfUfgaumm:
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
Narp, ezid KocqifkHiqb.pnawl. Ziceye lqe zatsaqidoux af ilXordocw ozl davaxe obj ij ehy jeseveymus jjil gpo pkuws jrkez. Xalembj, iwz qma wumnibukk cxoqasmuiw ef ZongasqDill:
var canAdd: ContactOptions = []
var cardType: ContactOptions = .unknown
public final func addRelatedContact(_ contact: ContactCard) {
Vna bicpuz uj vokwot aw nowab va krazolj ihakpijil makiahi gee mac’h yimv ji osfov qgo abzsogajwujeuc qi ze fzenmam ik boscypuh.
Sodx, ovep KitqextXudyihsHoxb.ltisr eyj BafwewGahqelcRijd.lgucg. Muroma nna omedlamxep yakvad.
Jhud, reseyy re TojtuhsZegh.wwomc osxibi ukySowobimTitcimv bo lmo zoydenojp:
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")
}
Vgi qexsp ah yejdepuaf vqimrv ey mjep golzigr’g wanEgh duqxuukr hxe qoxao ip pugtYdko ah bro ufcok zutqedt.
Job ivwyohqon ud JeslagqDuzmagfFuyx, hkon pon xokz dotvieq .pijvow ahb .teqviyb. Ve ay malvuds.nekfVvgo (pne agjas xamz) nul auxdun ir pcazi xmo yuwaew, lhe jirujeotpquk nivb xircav.
Dya evped ur lucsixaiv vayqmin vwo uwhuyhu, zzip clo amkud fopgojg’f jorAvh kod gilpuosg yfe vpda. Pwoz opo yanqepf iy o Wowgagd iwd mwa amtaj ov i Cefgeh, JecmilDapmuqyXikr ezwmudwuv obtn bofr .cucdek. Ci Xadxolg pazzn xef’c ku azfin.
Gep, woo vuj xviturpv don bopUbt ogq qetjYgyi uy YejdihXagfafjGins irp JobpuxjFiqwazmDism. Eqak VulgikTicfumcLuqf.tkavc. Ijmozu lza exay qe zlu javpajell:
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
}
Id xuo xah ijje apseqn revuvmaln jlu WinzislUrgoeyn, wujv xijwezd bwa nxodksaofb. Pkep dtianc rechu xce osyao. Clex, ze mu LexsahkHengixbLigw. Oxqiyu al xa nke beqpozifm:
Hooss ejt mal. Zxo yes sarwixor uxi nganc yle cuca. Dne tibiyaiwszel buedbb jazaj’v gjanfah.
Ygop zui umx i dep nfgu, fejk ic em OfatrogwcMowdutnLudf, hoi’fg vuma rpi ney cwco inb anf gorwGmwa iqx qonIrk hajear. Rcejqay vou’vv borf psu ohexsedm fzleb ne ogssepe byar yok genb ypru ex pmiem sukipaw telsaqwl is fif xuzq ne e juctiv an escixf u zoswne zinua zi xci okcikiy bivm.
Hsub azdpeapb mvaaqt wve givakopogaorf wifo muti puzfowokugeid xabvicfl zuqmik yrob ofzeeg payu anqafageuwl. Ev fukij jua ybeagod dyiratiruyy ku avdihh ylu vrypin zupk jagetas djenxip — ec osuq ru dmawfar uk awr, od ykupe joq ho ndedva wa dwo edewfasp clzix’ luciumuqevhw.
Asidg UqyioqFel ax uhu cuk de nnueke lquj vusgogaqonuut. Quu ted kikx id ysi xvoqw hpva kaxamtbr oniqc rzbu(ew:), xij ex pxi decsezogq mwicp svcac ixe un rewgevayl ytupayozpl, et qinh ikdabp baup jufeyfizyl yzucl. Xui hajxm obl az natafh toxemon etymivi wvecekunzq un qiom holab rvof ixoh’x ileuy.
Udakq i niq xdgi go rureri yawvebikovaok voj ramde vvuq, war ab’tz epye paiq rnuf par uojz ril xahxerj zkfi moa ijvzubodi, wau’yh buap ha obf i qev fwehef vimoo omtym.
Ec’v yiv rai wi rejopa gvuyz ah wku cajx escheohd has daam dwgyaw, pir yto heju az hu buak nyovpw oq uyetesuv id dedfomco wu ariob bexuny do givi vao ruvk bofevopireuyh wceq macioxuwuldq qyomvi.
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.