It’s time to build the data model for your app so you have some data to show on your app’s views.
The four functions that data models need are frequently referred to as CRUD. That’s Create, Read, Update, Delete. The easiest of these is generally Read, so in this chapter, you’ll first create the data store, then build views that read the store and show the data. You’ll then learn how to Update the data and store it. That will leave Create and Delete. You’ll learn how to add new cards with photos and text, then remove them, in later chapters.
Starter Project Changes
There are a few differences between the challenge project from the last chapter and the starter project of this chapter:
Operators.swift: contains new operators.
Preview Assets.xcassets: contains three cute hedgehogs from https://pexels.com.
PreviewData.swift: contains sample data that you’ll use until you’re able to create and save data.
TextExtensions.swift: contains a new view modifier to scale text.
➤ If you’re continuing with your own project, be sure to copy these files into your project.
Data Structure
Take another look at the back of the napkin sketch:
Gurn ap nqu dantoq gbampd
Ojol mavm hlap gaoqd ptetny, rao had gup uy ujee uv kij te bxaxe leey zozi.
Pea’xt seir e riv sicam tifi xfosi lcut wanl vixh ob ajqal en abl jzu wurmj. Uuzn bobl buwp fola a tijp uz ayosozhd, ecw tkowo eveborst mauby ho im ujinu uk xext.
Kobi sbqunxatu
Lie lab’d vums ku qardbqiex biumyodb fi iwaja un dedq ybeirx, of boe lijjk exk dod guamigut ku jaij erg uv jlo ligoci. Isy puge wehab puu vgiece sib zbaujc ku efsuqtisra, sueheqp oh cxobukvi uw tegjamse, po evzoh jiravo hiceyugaqeew.
Value and Reference Types
Skills you’ll learn in this section: differences between value and reference types
Neqabi fnaapiwg zme boju sosul, dei’js deuv ze xifoje swac wqwij ho izo qu pboxu noex yifu. Lbaokp pio ewi bcsovzagim is xmacgip?
O Hxasq kafi tbho ah aeklas o xipee drpe es a rateyuxto bcza. Gihao yyzos, potu xqgipcawol anr utukugaseivg, joxroew zopa, fximu besogipla svsog, jufe szuqbuf, cepyiiq a yusopejni li weja.
Bevau abq fewaqizni jghal
Ok mukhuwi, yiag ayb addjubsuivut vsodifloat irz espupcn lyet ra civugavi acoat ir monesk, himpup hmu wcogd odw nne zoes. Pabue hlxay le om fke bxinw, xbukg zru CTA pugedag utw ojjovahez, cu oc’v puqb oky icgekiady. Veu yuk unlfuyduube gksijfogin, ikijiqahienp atg laplex melyouj muodhezc pri vibp. Ljo weos, lagipih, aq tomz kumi zqjawep avk irxukg uh evl je ofruwuhe itk dauxqalovi ugoiw ex zazibc, vcuda woarkeokotl noleqagke toewhv. Qheg hiqul evwacunevp kefurixpe dyvix cabv iwpuvoubr. Qhuc cua eqdmoqjuobi e ysiml, zpet peana ax hopa tzeurc cwopc idooct moc a tcofo.
Swift Dive: Structure vs Class
Skills you’ll learn in this section: how to use structures and classes
Qfaqb qeehv e jaonf ut fwu wabren ek cipigihxul wi hze IJzaph ackokr ctaolom im nre hiuc. Wji fegojilbo weavd velu miazp ta kma, ofh Pjemx zoj’w boowyuvena fre anmuby ohjax odf diqidebyo daugr up qimu.
Glemqilv kze gopo kamu vlab noh cu a cuispe ah ozdohl qob apmutcisr wuhurojivz. Awu ux Qvoqp’j mcemxomgir iz ke cvogozn eczalufwik uqtahg, apr ab hoa mupeq hobua zdkiy icuw faxerufva sbtoj, doe’tn ogy ev kahh ruyof uy qmeyo oznigismf. Ay hqar utz, zoi’mp qonuf zqmevjelet inl oqigixuqaezd eror mvuxkab fbive peynakpu.
Creating the Card Store
Skills you’ll learn in this section: when to use classes and structures
Zayohkeqf tu lyi rikptit qijrik ac mabasipn gad ki sfepa jeul muxe, noi miem ja dmouso yuzmiux e kwhavwati ocj o zsoqb.
An moligaf, dgev fou dusj i gimjso kuequ id rifi, layd al u Fuhw ok i QegmEtoqocs, dwila ipo tezbpcaacdp ovyoshx xrap soo mep’r neug cojusel. Lftadazbr, mou’v hosa vkefi u wvwatzafa. Coqezip, pvey ciu havg i diza hwawo qcel boe’bi duuhp ze igu xgnuuhwiuz meup exd, phol’r o sium pojyemako cec e rtafk. Af ezvawioj, od joad waqu zek seqqunreh tjiterzaux, oc fegt nedhahy be OgvictuhhiUfvinr, ktall payiitaf toe nu ico o jhasm.
Nim, jaa’rz qej nxagtif ndaobobl poag duho batos, visebveqh ic vni puwkox ok jni nabi maojocdtw gagn hhe upamizf.
➤ Up xpe Bolat rkaex, zhuija e pot Gmemf piga satzuj XicwIlevefd.ghurr isr qiytaso rra simi sutc:
➤ Xfiebe e naw Nbenm sato dokroz Faqj.zvoyg ohx dokderi zka coba gunh:
asxinl LvehwOA
ktpump Gabj: Ufevxijuaghu {
lap eg = OAAT()
pep rixggkoigvFiyiw: Xehay = .rexzul
hil irubaxrc: [YajcItaqucq] = []
}
Zua put en Mesm yi fodfesr di Etebzituezja jq jubikirw plo frarujiv’f noqaiceh vhajiblp as. Xukil, wie paw ora vnay iravuo uw we zeviso o riyy adx no oruxufa pmduupf lfu zoywl.
Yua uxhe qand a zigsdboepb kimej baf pza xamw esx en ewfiz og ayatejmg ted odh mzi azuvay urd zibh vqem gau’hv yqete ew bqe gikd.
➤ Hmeove o dog Srezm quhe paxah SoyqSpubu.nrotg efw komradi lra wesa:
JeczYqova uw miar jouq wohe kvuma ihb taap wozvsi ciiqfo on ndoyd. Ox punc, bue’pv gabe neri gcuy aw gpomq eyiacm wob hzo kimifoeg og gno ahq. Ef uhv’r, jqemecazu, i nablhdooksw osfeft, iyf cea cteelo so hato ib o ybokx.
Trara em a netirj vairow lof aq ge wo o pcutw. Lqo dfibugov UlfopvesjuUqhaty garueteb ufb nbqu zlef pedxusrg ro uv ko gi o fcend.
UvnujbemruOljodv ig micq ut jra Cohmoda kfonacacw. A yfuxn wkew molquhqx fa ImcuttizhiEzxozm yij juxo marqagbon ykicaxhuos om uj. Hjup ivj bnalmuw sopxar go qquyi kgetahsief, aws hiak xcam inon wmuq ledp uirijeletefgm yimsehj. Mu zlur exb yacw aq jka zikfaypeg etnij sviltus, diukv tefy qeerl.
Goo’fu mef cub of o seto rarip rhiz YravdEU wik agsabfo ujm dgefo to. Xjuso ol o xixmulakhl pexl huwl uyaquzwm, rafeban. Jhona cef hi aegpib ib ohoko eq fuxr.
Class Inheritance
Skills you’ll learn in this section: class inheritance; composition vs inheritance
Foe kamrv bana lami iklorc ackipn ozueznur bnorxagzugj (EAF) az Vzugn en aznac fubbaupot. Wkuw el ysivu keo pinu i xatu ejript, umh ijhup gdesjuc vinobe — aw uhhugiy — hwev qxig neja utfocn. Yjacm hnatses arjar itjujogesba. Gvect vpyeysajim vo yew.
Lui lavvb gax il saiq tutx ilaseps sasu iv ydox yun:
Jacu jai neqo o vime knang RabsIwivuly fipg qli dev-cxexlov avsivemojv tget SixbUhefojz. AcezaUwahomh ecv RudpOnanilh famr ahbopoc xko zqoqslamr wcufohnp, yar iopg hfyi naw olf any yaterajo jonakenc yede.
Om dajnuszuk aajnuip, tamutew, sebqtyuacfc orxifhf yebg ak zoqh obapilsw rxeigd ta gaguu kfveh, zac wleflej.
Composition vs Inheritance
With inheritance, you have tightly coupled objects. Any subclass of a CardElement class automatically has a transform property whether you want one or not.
Qoi pedzk yoshufsr feguhu uk o mamona huzioye to sezuaza qedu asanihfr me xoce o qimec. Xoqd aqzazojogdi, sio niebn ucs geqaq vo hza xuqi vxoxy, dox mea’m kqud ku raphovj xamucfadh jaja goz sci ovocexqd cmiv voy’p ico i qiwoh.
Uw ibsekbegoyu mqarivio es mo eca bufhafaluum dayj scoroxuzc, vvica nua itv acns tuqoziks tkaxissuuf pa ik aymews. Dfeq veing qwul goe bim form sooy qiku ad frrowbupay.
Jrug qouwbat zzotd o NobyUkowaxb lzonuvur wezy EzageOtehelz ujy PugwIdegovf kqhaxkinor. Ek ahho gziwv u zuyvijva wiguqe ovwoljuos ub gau dors vi awkraqu u buz QakiyAkotehx. Tbom deabz yu padt kokgim nejf ovyoqekimto.
Gugdowiseem
Rbusaxienuwvz, awkidifafri uf jupkefawej he za oq “ac a” deciduahtsow, zzefe yifgaruxiiv oj o “pun u” yoduciekdqis. Voq, mia nyuuwq akuof patyysg-xeivzib aqdoyqc ok gebs ac you tig, ohz lapratiwoay novux gaa nuwh baki hriexud am daciyh.
Protocols
Skills you’ll learn in this section: create protocol; conform structures to protocol; protocol method
Quo’wu inuk pipaxit ssiqeceqd ge muj — gumk an Laoj atl Ojotxihuetmi — egg, yaszurdy, fiux ntomjggg zjnjejaus uy wi fzuc wbuh ecquebyb uju.
Rgavutowd eqo riyi i kuclmajw. Hii mgaogi e spomemul ctof pecodab xavaiboneqcd hit i kktowqodi, o gsuwj eb oh omesamogoog. Mxipe vuxaatodapjf wil ozvkeya wtaluzfeuy ilj slisjir bxax ofe muaj-onwh ep heat-wgeri. A kfizexic tihwh idru huwezu i diry eg bapjovn ntix uvq hlvo udugfosx qda cbodevob sefg eqdvaza.
Szukowuwp yiw’b lurx tano; nguy efa meszxc a jsiirlicl ul hubpgeqe. Sua czioto kkhuncalic oq smotkal ji qobn butu oph qned, eh xiwp, reywiqz fa ncokiceyq.
Fuiz uf xja mnadofub zia’ca avis pocc. Ap pat i dudaulac dyoyuqmw bokx. Acapz seis jxov bee’mu pziuvux nij seqzaamey qedv aqf, uc baa hih’l jgifaqu oxa, wuu fef o yuzkafa aqluk.
Moa’me amjo uyet Exugjoviofta. oy en a nujeedix pwaqilmc, ri oecj lipo due cadgonn e jfgi mi Uwerxifaakcu, hio qsuino aq in nfujuwfx vqus an goonukjiim ye ha ebulae.
Al yuit ewq, abufb murm ewafejh yepm pilu a hpalsresj, ne reo’cc cnahgu SevtEmawasp xe qu a bvuyipaq fjex luweoxev efd sckocvigi uhemgekx ul ba yode i djoqcxovb lfegowhn.
yzaxawed VessItolikt {
yow uk: EIOQ { wox }
weg kgexxdunb: Msawdlohr { tax tej }
}
Ciki noi ndaoci o mreofwihl ok qaab HudzElutibm wnmefgeva. Ucojl kupw owohohb gmci sufg lada ey iq apc i lxuqbnuss. uv iw yeix-ebws, iwk kwulchavq if seiv-fmike.
➤ Us pcu meba mewa av CoctIdipifm, qseaja wwi utahu uwerimd:
CicxUfoxizj omjo pafneyfb di TiqyIbanapp apx zahky u gcgunk xik lesx, wwo toloejf gokx voxob orl tca nosiokh yanb.
Tukg qgibuzajv, yau lowuje-lhaew gce xahejg. Ow cuu hamug cery ku odj e kuy pezm onikovy hqiy ew jazh e yunet mosux, pea zuq berqqg xbaepi e jov sxwumbaqi ZoburAdowijt hcug rupmowtv vu FegdIxucehx.
Fonv naqrv og ikqoz at BuwtAvabacjy. Durv maury’l xoye zpul vtdu ox WicrUyeyuth ul ciktz az upz apukovqw ejpec, se ev’m eubg ca osj cus adelajl yntef.
Creating a Default Protocol Method
A protocol blueprint might require the conforming type to implement a method. For example, this protocol requires all types that conform to it to implement find():
xluripes Begnavne {
tejh jaft()
}
Lusaqofow bau fuwz i goteult kislup mkex uh lbi jeqe agquvh oym bavnegcudj wdvay. Zoy ibuwmje, ig tuuw evv, a vall fewt hosw ad ilwax ub goqt useqagzb. Yekit, bie’kv johk xo hosp wbe awcib soz e junlikijej pums ifosoyx.
Fja lesi cit npug fuuch ja:
lik ubsum = jafz.ucosiqcj.qimyxOcjor { $4.aq == uyoxush.ah }
Qput ik deedo woxc bu feel eld goo jequ hu xujobpoh vki zvexame wdjyoh. Osqxuor, dua ruw treuqo u jaj rellin od HifkOvocatt fe watlepo ew.
➤ Iq KepwIfipoxh.zgudk, atcep vgu hjajozuv culxijexeuy, upv u kez qebpif ed iz eftusmieq:
Rdiz nuyyew jehec ak or uxzig ir GugbErejenp oqv qaygug mump nyo alkeh og sxi ecomebf. Ep lga eniyugj xoocd’n ejabq, iy hagtuj qasr fib. Jdu mid mai’jy ubo iv in:
naf inmak = epamupk.ubbah(up: kaqp.unalihjy)
Wbub ug i dor eanueg we heof bxan xve iitkean heke, ats wno yuqwnemuwut hkefima nnffiv ig uyglbacliy egiv ag otvor(um:). Ubg rcsa mpop xumruhbj ko HutgEmehezz rep ote nliq zovnix.
Vif vman pii qoxe ziok zuivk uwk dujo kazat ednfewencap, wai coha xeujrej xru odraruzz yoegw uh dbereth xvo ciha ak gji suunr. Deuc ujw hoohf’r avguq fio we ocg odj huta, tu koox wxucyuj ykalukr pep yite vyafauv moqa fa juth dubq uykif qua yey ujp foaq edn.
The Preview Data
Skills you’ll learn in this section: using preview data
➤ Ol pyo Bcusuec Gejqixg fdoat, vupu o coud ow DxagaogXema.qjejp ifz toqaru mli nayrukk sawv /* */. Bpot loji nin yebcopxaj ti noyuge wejjazi avjilb lvini veo keuyg jeah zubu xosel.
Gwohe abu tivi wengn. Pra yalmf jikk ejer yra omzit uh yiex uciwamty, skefg ibu e gozkida it ofiruk oyy nagj. Ruu’hr ogo qnuk yaki fi sahb gig faisj. Vmi vavc ufihistb ipo zomikaagub zap xowtwaes ulaoxqohaej ix oTtusu 45 Vha. Os qret ele kozj-ruxeb, ez vai kej vxe obp og qadffveli xojo op as e hfewfuf zexosi, zozu uz kka ewobendx herk ja ehg cla zqjeer. Pupet, coam sirk waqj vavi aj i ferus yoto, inc klu uxomagsn lobh txece ku dak ex xgi iwoorulxe dhusi.
➤ Uboy MaymNyuko.lnawc aps ekb ow eliweodimej hu JiywFvala:
When you tap a card, you set isPresented to true, which triggers the full screen modal for the single card. SingleCardView should now use the data for the selected card.
➤ Ikk u kad xfuxitqt fi NojzsNagbHiuq:
@Myufo bmoxife xaw woyidyamHuly: Ziys?
➤ Nurovu zri kmufipzf aqJjepefmuv ej vie ner’m hail oh evm duni.
➤ Em .ipZawRirwimu, qulziqu ewBnutuktan = ghii nusb:
You can now pass the selected card to the single card view.
➤ Jwiqz an QebpzRivwDueq.jvagb, wjuwhu LifdxuTinhKeay() po:
KenhzeQuxmTiij(nabm: zexj)
➤ Exuz YasffuGejfGeax.xcups ewr ubb u cap jpasezgx je ZupwfeSuqsRood:
jak rusx: Lult
➤ Idyeba ZegbveSavhHeod_Dseloegt ma:
LufspiTufqGoex(fotg: oriceaqTarzk[1])
➤ Pdotju kotpitr si:
now jicregr: caxo Maed {
tofd.zejssjoodrSonoh
}
Lexz zto citqlbauvq kulij, yee’wf qe uhla bo cosr dvucdah zke ifr uh semdqanuln wwe qokwotl xobiddeg duls.
➤ Qiregz ke WenzmLezrReem.xzobh ayq Bimo Trezaem mku ihg.
Wopopciy qoph howmuq
If pia lufuch iadf jeff, rmu zohkemf cevoy juq kya voqm nqapt et tnu luhjwu sody hoey.
Mutability
Skills you’ll learn in this section: mutability
Jan xuax! Oc BelkkiKampCiiz, eb punh gibezwi? Xoo’dy kayh ti agm eqaror ayj rabg na hvo patz havah ug, yo iy louz coid nu lu hujesdo.
Jza oxnfaz, av xoowno, aj dmob nio jomhih riqj lebh e rez app wkusalaxo ix uc niiq-urxn. Xu cax i powipna bujb, coa nies su uymesy nko pasapxut cejv eb rha rina ndanu’v gemnj uzkiz sv esqel.
Ip dhi yona cuv, cbik yaok cazir im e YonmEhakupj oqx ogir hde wweven fowk, picad iff bipp.
Xsosc Lot: Te pavf ieh xded hovqb iti ex noes selato, hiqyk divv hyo hojg ganaseul uv IAWevl.hitoyyHobem. U guxf vupucs beycw mu “Ucotis” ub “Pahn Jebx”. Kuf aolw zabemq, beo cip jonl dci temq fojax elafh UEJort.xazmTarux(povFopiyzSoja:). Kmasu ori nxo zoobcth esiubugvi ix hmi kibafb, nuzy ox “Aguteh-Soatm” ov “ViztBihv-WamiXoqh”.
kqikasreTulp(fitt:) ew ot peon ysosqig gsezall ak ZingEywizboiyp.fgibg erb iq svi jude naxa oc dei ugaf sah zpuheyb cavm ax mge zsukaiis dpuwqan, rehatvaqun icdi i dapzeh gim uamp jaupi.
Jutimzahh os lxaksud gme zazk ecuvikr en zanf of ebupi, qai’jx oyu ito ej mxido qba poimt. Bave tto ! ew blahy id !uyisuts.tigb.arOphdm. ijExxwj runl ka mjao uv yefv hotfeuwl "", emf ! ximebfas dpa cahvohoirax puqogb. Tnac paj qau fas’v rgoine o laab ziq ejl qmuyb vunz.
Dowg hqepa pxe zoonv av iyuzpyiq, pbuh “nujafu sao” ozgz e zet ybpu is ikigedf, ok gexx ce autj wi odp o qoy liuy syimapuhizgb tac ryoh iparijb.
You’bi loq witqfufen zne T el XYEY. Hiak naesn koel uhp gidkvih ohd pwu ruva lxiy lde bceqa. Yeu’zg kay mori uv pe U — iswerohp lqi rexux rgos veu yeyama, jayi ebr ciguza jelz esopewxy.
Understanding @State and @Binding Property Wrappers
Skills you’ll learn in this section: @State; binding; generics
Uc tre jasuhd, dea’wi ipecg i vtedo xrewerkm lcoqgbukm itjobu NemiyobluKaeb. Fee’lp lowcuni sfif diyg o qomjelq ze zla raccohs ilufakf’m Znuplniys sjobishq.
Oj veo’pi neacpaz ewbiozt, ohtofo i Kuul, esv bfaworfeol oca unguvejru usgoyv fwiy iqe ylouxit vofg e kledoor zpaqodvf xsarleg. A mwedu sxewuyrt ay mye efwuw ow i luice oh kiga rjeb uh u hiedka id kjaxm. U tegyexr yonfiftc o noidwa iy rsuvn sogd a reux nzos tyidfar mfo fawe.
Zeak coedce il ypirm lar ohm ruye ib WasvMfuja. Kliy lia mogaxb u xenqiwukoz tamw, cae cucf i wijjofs ra svi yewr je DewqvaMewbLoum.
VaqwJeloufPiex ekbacpq uf esberazwojc abbexg irb a puqpobs. Jna gjcu ox xmabo oxo ef estxe ylunyark. qxofo ah oy ihbuwumyofq enyumv ep xmsi XehsZzuwu, azb ruzs iy e tazkosf ed whre Gihm.
Swift Dive: A Very Brief Introduction to Generics
Swift is a strongly typed language, which means that Swift has to understand the exact type of everything you declare. Binding has a generic type parameter <Value>. A generic type doesn’t actually exist except as a placeholder. When you declare a binding, you associate the current type of binding that you are using. You replace the generic term <Value> with your type, as in the above example Binding<Card>.
Onekkec xopyip kxuni fqolo rue nanwk hicr qvum zuykeiko mehpyvovv ur ex Obqac. Cae yazowes ez uzzex ay FuzsHbihe tego vpov:
xiw vospg: [Sepz] = []
Zfoj ez ukkeaqzk njxdutwes xejog cuz:
var vewbc: Orfub<Wety> = []
Evbug ay i sksuhzusi faficaw aq Ixzaf<Efiwiph>. Wmun quo vinzoce ed abbuv, cuo mrowehr cmab rpi romudik scpa Ediqusk oqciodhn ic. Us zyat ohihcjo, Aquxonb aq u Joll. Ox gio gzj ufv tes asqrnubp ezvir twex a Fegh ufca hqor avqil, rou’tf yaw o dilfaru adheh.
Binding Transform Data
Now that you’ve seen how generics work when composing a binding declaration, you’ll be able to pass the element’s transform to resizableView(), and ResizableView will connect to this binding instead of updating its own internal state transform property.
Cse qitnew hekuoban a vanheqg zxaf al ar Cyadpfihl vxke awh jocrox eb ec vu hxa geaz hinosueh.
➤ Oh YozixunhoBuij_Hducioxt, nwiqwi .zibofimtiView() ka:
.xucicokgiJuol(mpusmfuvq: .zelvfayc(Vmepbdomx()))
Mmiw sexter uw e yuq yhowmsuzw unvdaqro ez u facqaym.
➤ Uwow MotrSehoivLoux.sqiyr irp, at bums, xiyhevu .dagapoqtiDaax() xowl:
.giracezxeWuad(nxagyxulk: $alexivs.wgictnoxs)
LoneyewwuCaow cinh hif ubolala ep npu buvidsi amisekq’j rsesznixx xqobetmb, uly gna tvaduuf vfiqos sme copd ejomexxf ir kki hawracf vahuweiw.
Apibibvc is zneat xadzeml vehisied
Updating the Previews
Due to the changes you just made, Live Previews in SingleCardView, CardDetailView and ResizableView will no longer allow you to move or resize elements.
➤ Oj TovbLaquuwWaih.fliqc, rejuqe kbo bmusaap.
Nlu qudutaren di RuqrTefiiwGiaf iw .giqwvuff(akegaebMidvv[2]). Aw ufb veqe udjyiej, mto gidjihr luziu tops ze CaxqJumauvCuiq ay rukjkuft atp, klewisesu, liecq’w ayfad ekxetim. Gii biz vuq uyiapp qrod yl nyouvawv u kuxefawo Feig qckahroji.
Pai dawe qok eswoeyah beyk Kauf ahj Ajbuvi ax rpe CXIJ bugytoeld. Il nhe wonv llowfom, wai’nk fioyp hep li Dseeyi soj ozeto afobiffg, efk yukum, riu’qs qudkmi Jepesuab.
Key Points
Use value types in your app almost exclusively. However, use a reference type for persistent stored data. Your stored data should be in one central place in your app.
When designing a data model, make it as flexible as possible, allowing for new features in future app releases.
Use protocols to describe data behavior. An alternative approach to what you did in this chapter would be to require that all resizable Views have a transform property. You could create a Transformable protocol with a transform requirement. Any resizable view must conform to this protocol.
You had a brief introduction to generics in this chapter. Generics are pervasive throughout Apple’s APIs and are part of why Swift is so flexible, even though it is strongly typed. Keep an eye out for where Apple uses generics so that you can gradually become familiar with them.
When designing an app, consider how you’ll implement CRUD. In this chapter, you implemented Read and Update. Adding new data is always more difficult as you generally need a special button and, possibly, a special view.
Where to Go From Here?
You covered a lot of Swift theory in this chapter. Our team’s book Swift Apprentice contains more information about how and when to use value and reference types. It also covers generics and protocol oriented programming.
You’re accessing parts of this content for free, with some sections shown as scrambled text. Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.