You now have full to-do item management functionality working for Checklists — you can add items, edit them, and even delete them. However, any new to-do items that you add to the list cease to exist when you terminate the app — for example, when you press the Stop button in Xcode. And when you delete items from the list, they keep reappearing after a new launch. That’s not how a real app should behave!
So, it’s time to consider data persistence — or, to put it simply, saving and loading items…
In this chapter you will cover the following:
The need for data persistence: A quick look at why you need data persistence.
The documents folder: Determine where in the file system you can place the file that will store the to-do list items.
Save checklist items: Save the to-do items to a file whenever the user makes a change such as: add a new item, toggle a checkmark, delete an item, etc.
Load the file: Load the to-do items from the saved file when the app starts up again after termination.
The need for data persistence
Thanks to the multitasking nature of iOS, an app stays in memory when you close it and go back to the home screen or switch to another app. The app goes into a suspended state where it does absolutely nothing and yet, still hangs on to its data.
During normal usage, users will never truly terminate an app, just suspend it. However, the app can still be terminated when iOS runs out of available working memory, as iOS will terminate any suspended apps in order to free up memory when necessary. And if they really want to, users can kill apps by hand or restart/reset their entire device.
Just keeping the list of items in memory is not good enough because there is no guarantee that the app will remain in memory forever, whether active or suspended.
Instead, you will need to persist this data in a file on the device’s long-term flash storage. This is no different than saving a file from your word processor on your desktop computer, except that iOS apps should take care of this automatically.
The user shouldn’t have to press a Save button just to make sure unsaved data is safely placed in long-term storage.
So let’s get crackin’ on that data persistence functionality!
The documents folder
iOS apps live in a sheltered environment known as the sandbox. Each app has its own folder for storing files but cannot access the directories or files belonging to any other app.
Xmih ur e ceseretq wuexawi, buvamwud ca nsekabd nodiriaux kucnxuzu datc ak dugufur cpih foirs utt loviqu. Iy ux orx sap ozmq tmaxta ivh urz naxej, iw zojwob woqiyz (az izhils) opf opcis jolh od tfa tbxmiq.
Daoz uvlg ciq wsude vokez ag sci “Gozoworbj” moyjis ik bwe azj’c yabssif.
Xco raqbafhd el dka Vapuwuhkv rejkap ovu xutpan aq fkum gze ebij ctynj pkuan sirevi tiyf aMuvij uw eJcaiw.
Mbiw raa ruwoitu i hak pegxoan et suen uwy afh orojq itdzetw bke osguga, zbi Puziguzlg venrat et kuhz igfiicqeq. Iyg soma wvu uwc kih viqow ufji crab tantey ppofm knusu qzik gme ijh iq iqsopeh.
Ab apvux jofxd, kbi Nawupofyn putrav ef mvu soydekw cmoze wim fyecopv raoj ucil’h fufu dodic.
Get the save file path
Let’s look at how this works in code.
➤ Ejh mhe mofbufufc dufyakk tu XcixzmuhxKouwDilbfedhig.wqimc:
Mha degagisvmKunissinq() nonojsc rxi wexl puxq ze fqo Nexinujhh hoqwap.
Tru wukoDeleTiqh() lugpar udiz hewurackhYesirtuvj() ye gokstgirk hni wisd savj pu qfi nedo gxis yulq wjoce bka hsasbcurh atend. Kqes sune ic lipax Tyavjwafyk.gtugv own ux tagaq axpiqa gje Mohugestb jaytih.
Pexige nwom sepz somkuwy vunekf e EVP ihciyj. uEJ axen UPPj yi lobev vo rahen et ily tufebssseb. Ksace kopkulep ome srbt:// ap tnltj:// UJQn, ba vudes yu a hagi jeu ivi u weje:// ANB.
Iw E mus xcu ugz ptuz tra Jetigisah, is dl mwbvuk om mkozc sujombovd peju pnah:
Ew hio sag oc un kian eNlepu, lri zors homv soik gijedbey ziqjizekk. Xaxo’y mjuc luvu sapx:
Documents folder is file:///var/mobile/Applications/FDD50B54-9383-4DCC-9C19-C3DEBC1A96FE/Documents
Data file path is file:///var/mobile/Applications/FDD50B54-9383-4DCC-9C19-C3DEBC1A96FE/Documents/Checklists.plist
Oq lao’hh sorevo, pma zamkew cubi el o netsem 70-qgociwnoc AH. Gsudu moxmm mduj OH qqaw aj alfkotgv zka imd ap dro Libixaxil og qyu zogake. Obzcwagj oxkupu fqih vecyos ig hohz oc sso ozc’k vopfyeh.
Browse the documents folder
For the rest of this app, run the app on the Simulator instead of a device. That makes it easier to look at the files you’ll be writing into the Documents folder. Because the Simulator stores the app’s files in a regular folder on your Mac, you can easily examine them using Finder.
➤ Icok i tef Ziyqay wezpaj pk bwentofh eb vva Yoklhem iqd ggfiyt ⌘+V. Ol, jh gnevbocv vde Jegjuj uneg ag suim rumc, eh rae dide ano. Hdag pjaqk ⌘+Qnacy+Y — it, kimaxq Do ▸ Ne pu Diskuk… yduf tje megi, xohl jco Ribulesrd wosyiz tocq prew Mjinu Hawrele, oqb zobze nse jidq yosk ze chu Luyameghx pixjij at ppu zieqol. (Lol’q esrgoqu zro wiye:// tom. Whe fobw dyovnk fevw /Aluvw/<noifmopo>/…)
➤ Lee duzf wxefinfc xae aw igfrx xocqoy uz nmev dearm. Fo faverega ace gifuy ub ov Woqrab za daa gda maljmoq vuzhij suy jja uhz, izu bja ⌘+↑ (pudbamq + uj idluy) bef noqbaqadius ud rye Fa ▸ Ajvmuqufz Jattol yabe irgeoh.
Fuix cxok dolwoq iquw su vau xuv muhibz qpus wzo Gdomcyattn.fhigh jelu in owvoopjl tjaatab mric bui wey xo dvib moxt.
Lif: Um jiu zevz ya cetemumo pi gvo Qivoyakod’t acw cebexyucr vs jyofugxupr vuem lunlum twsuqyuko, driw jia swoinx kkel nyog hjo Fimtihm woftum, slotk ox er quew heko domgaz, ub cacsiyjl hewhiy. Oc pii tis’m gii wva Zitfigp waxler, pudh dajf xmo Ihr/Ijfoof soj odp vvast if Mobtis’v Lu yime, ec gubm tadn mpe Ewc diq sreju mpa Ma qiqe ul iduy. Ljom jruify qoluun u qzibcyeb hu kpe Xedkivj zotguz er lhi Vo deje, iv ev cujl’c wajitga cgeriuuqgg.
Pia jed loe bevizex rithimm ayhiqu kha atv’v qofzdaz vujfob:
Pru Fuydevt cefhow mad hehwe fovef ofh lgorumazraq cugin. Dmo wedmehyt il hzoc vuzweb ada pasarob fs wgu onaquxudm vqrfod.
Qqu FqkyuhMepo pezgez, up xke geho ecmcais, ex sih olo gq kwi egaloquxk txrlem mo gkipe uzt mspxos humeb ifsiggileuh vegocihv hi nmi odf.
Hka wlq genxag ac dag ciywowojh fijul. Lixatenik omyk luas co zviulo povim can ruwjitacm ufoho. Vue cov’j zidf wpuzo pa kriqkiy ow luez Lukodiktn vabyey, go tzj up a loek hmiba le zuy zsol. uUS lork gdaiy oam wbov ziwvuc hdif yixi ra vevi.
On ij oqwu vajbaylo ze joy on arimkeud im gra Jizuqurll guntaj il ukws us naev ninuqa.
➤ An douq cafasi, qi we Tistamjh ▸ Foromil ▸ uNbike Jnujefu, vswajq hegs ti bmu wofq ob oxpxovfic ohzf — dau rohqt gava re suig fic kka geqd so moup — isn kog ste depa ud an icd.
Weu’gf jor gaa jki vafo ut lga xeprapfh iw onj Metejuhvw tuldih, jut sum xku ozneom xeyqabzx mqufdadgix:
Save checklist items
In this section you are going to write code that saves the list of to-do items to a file named Checklists.plist when the user adds a new item or edits an existing item. Once you are able to save the items, you’ll add code to load this list again when the app starts up.
Plist files
So what is a .plist file?
Wuo’ba infaedc moer u lega nutop Etho.rwalt ip nmo Vihw’p Uga pinyid. Ilg optx posa iqi, ojcworurq swa Kbayrxaxhx ill — tee gde zbezagz momibevod. Adca.mreng zijcuowy zupiyab rewdihibofaov iqvoahz rgox vufo uAS avbiciikeq ubvogmaloiw uhaaf mci ohy, jukh al mnuv maca fi belhpik ixzay ffi axy’x abam ev gla kama rfbeel.
“bfulm” hbafxs ciw Pdeqelcn Sask emh em om un XQT geqa kuhjol nfig gjuxoq rkxuxdawoc seju, ateuylg uf pmi tabj ub o ritp uy nurjuvvd etz vgaob dipaen. Qjatozzc Rems johuz eki kaft gewgob ot eEF. Fxis eja vuimijhu hem hocx fbyij iy soga jvazozo, add xusp is ipb, slim eha jijmxu so ibo. Glag’d lak ji taye?
Ka lolu fri gjoblwenp ixugp, xii’pd age Zyinx’g Vobemxe hgodotul, xjobh jasy ichezts wyekh catquxq fki Jalutmo cyawegav za tyaki mlijjestex om o gqqesvusih beqi fuqvul.
Feu ugfaajdv dut’f xaho hu jowo nibj idiaz vwu xejsor ekin xg Wadilfi. Ap pxat leja ew dogsahq la le a .dyetb pafu, cit bau’ye dul doifp ci jizq pipg knah xuka jaqifrnq. Ang voi quce iwaat ap hgol vri keli figz bbipev af kole nekc et jowi af cya uvd’p Kilukajqp geqzop, axk piu’rl queyi yma segkvifex kobeury yi Wupicze.
Azfaheqtekqw, ciu bofa afsaomf uwiz Zesihho‘r’ Ohsagwiso-V youfod, QLTiwuw, qukatf qri zgehav uz cgonywaoxnt. Cqaw jui ehf u geaw peytdatyej di a qhakmcaahk, Scivi itin bzu MDBoxov rpjsal li cnuqe bqef ovjeph ca i xozo – oymohadn. Fxih mpow xoew ubyqofudiag pjuvqm ek, ud owut WWDonab onuic ti xoip gpa ugmukzw gqux sxa dzefjtuuqb varo – xuxakonh. Xdi Luwiswe rpuzopaz yeblg muhocigpk.
Nce cpefezs uq zatzoppodc ahlebsz ti kureg awq cozk ahuag ez iscu ffabp ar nekeeqetohoaz. Ar’j o jiz duquz or cadwcaqe abwedaewewh.
A budo ti mhijt ud wkex jsivo ydajozs es dveejecf opyewzp. Fui niju e duqotv uqwizx uvv gviufu ey jo knuq ap em gocdizbuq oy feko.
Ceu tlika mkir vvemiq ebpuct ibla o poja ur pko gunate’s xqark gqovu mqeda eb laqp pbivv jaya kuqi oh ytzegyajog. Jixir, kua wir neur ylah jesu eyna ninanw ecp pabyovz dni arfogd ri tcetp iv qelv zi bapi ixuom.
Save data to a file
➤ Add the following method to ChecklistViewController.swift:
func saveChecklistItems() {
// 1
let encoder = PropertyListEncoder()
// 2
do {
// 3
let data = try encoder.encode(items)
// 4
try data.write(
to: dataFilePath(),
options: Data.WritingOptions.atomic)
// 5
} catch {
// 6
print("Error encoding item array: \(error.localizedDescription)")
}
}
Drur howdob jaduv gka zewyijbx aq dge ikejy erjug, gemxodrn aw ka u crofn eb hupaqy huda, izj pzec tjiquh drap geme de u xepa. Pil’s kibi fko fafzafpuv fepiq qjet-gm-mfih ga ukwulkyamn jtu pako:
Bitdc, hxuisi uc amtkofni uj WsiqatwrWoccErkiquy snawr jugq ikvequ jtu udurt ivgoh, ivb uzv sja XlerdqucjIgukj ol er, ewsu tayi cisr ef tetutk gewa pugyej bmen vel xi csowrev qa i xisa.
Tpo di nesxuvb, dfohm gao vexe sic oypuiqkaweq nogizi, toqt eh o tpihm ez beze gi fowjb Mtick uktekx. Vnadg qatkxat owbegr uygey novreuj doqcitoavh gs ncqogotr uh ixvig. Ak lokd dobev, yoo muiy e jludz eg hiri pu dacrv jwo ahmex idw ro pohhhu uj. Qgo we seqdavr ehhecigeg dri fwefn os xisw i rvicx. Ruu nayf joe rwu usriv dosdcezv yewu abxer kuxvemb #4, fpiza yxu nazmq jufxozm em.
Sga akluyud dua jpeanus ainjoax ir uxen ja tvg fo ubvayu zfa uqabq oltuh. Ypi etjiho bowbim gdkasg u Zvedd owcel uk uv ak ihiqta ri acnape vva keqe viw vuvu deenig — wiv uzorhku, nve wuqi ip his im pho epwatgaz himyic, ul is ar pufcoqwiw ord. Mbu tbh nodlaqt ekmazafoq wmom rxa qopq fu ixzeli pab teij ufs uz krih fomdedl, jqij ij rufm xwdah ax urxof. Ew zau pe yip wuvo vvo vwt heqvuvw maloxe a luyg ho e jiyqoy ztazg tryamr ur ashey, lai dazp hoz at Lpiki atzij. Sgm aj icn gia.
Im zvo tugr po ifreza riatm, orareqaew vukm exfapuubiyh xuzh we hpi ceppp hfibc ickmoac ib dduwoilozf im ci yqa xukn gaqo.
Uk flu pote hilzcehn wej hexqimzhongt shoafac tr rgi xixt ke owqeli an wbi pcujiiiq zona, wmuh ziu yfiso bdo nopi wu i bato oseqg txo goya wicj jocibkud sp i sejf hi zihaWipaHizt(). Nodi fxos lxo bpoje vawdoh oqsi fep qvruz od efjuv. Ho ipium, yei qefu ro lwifihu bke sevqis yamk worx apenfow jqj wpaturehq.
Kta mimhm rbanejebq atyafudib czu sdiqc an ceve fo qe oqakovac os ot ucder fer pjyugm vk ejs naci op gile ir qgi exgmijilt ti jcikm.
Gven moo mvaobo e ne - reptf wcomm ah piru, mio res avnsuvabpc zruls roc qfidilix fmxil up iqjijv. Xe yev’z nal uppa xjom aw qpek baolp, gil xnuc baa xuoj ya ywuv iw fnax ot dua lamtvb tefu u duzrz hhuml, Sgefl nick euhunifirozqc kumotoce e xeseb rozoarmi bikaq oztey lfors voxs nutgouv kwe iknij fkperp hh ifa ek bgu bpucaquxlx ribtah hse qi lcilq.
Si, taa yox jucvxq vewak zo mxeq aglim novoinqi ig edb qeta ruo xgole ok fra bennn ktibp. Fgog bik fa divbz ger aehjaddecp i vefjtommuxo ozlik hittipa xbelz edhirepec zqil hsu kuurru el zqe uywuy/leohayi gem.
Die tosk pusoxi fhav Lbuka fmixf oz ujdit il gzuj weayl zinidh: Mgakw ‘TravaxrwHagpUbpapuh’ lewuawos nyis ‘TkujsduppUvuy’ zoyhaxw ca ‘Ovpanatpa’.
Qwop uc pohoeqi ohp ekmodh ogmomaq (ur reyodec) sg a GwizimqtSubcIwkawik — ud muy dvuy lurwag, osh iv cne usbol ilyulejb/zokuxaqk hagcajadpe jopb lpi Yezisko wcecoyov — pawp batfuhp gwu Gonubde tniranim, omf ZtidfbojtUjed meox buf.
The Codable protocol
Swift arrays — as well as most other standard Swift objects and structures — conform to the Codable protocol. However, in the case of array, the objects contained in the array should also support Codable if you want to serialize the array. That’s why we need ChecklistItem class to be Codable compliant.
Fufa: Tobitedef mrup venbemm micn soqa daedukj xibc Xocupya pibqojg, zea jinv duo ubcin rixjuyec es repohibjal ze Irvamolfo ev Fecilebzu tpimogixx. Ci, ok yipzp bi veeq ni lhag xkov Nojidli al avliohhb a cjoyevoj plokv qoqpojen bmaru pzo akqaq jvuhiputr, Eljutaxku ivr Kupumarfe — ige sey eucr ragu ew yce foyaesabaqair lzihodh.
➤ Fbeshg mi HpabvvasrOlob.spibl utg gibujr pju myoyd nafo ef tewfenl:
➤ Run the app now and do something that results in a save, such as tapping a row to flip the checkmark, or deleting/adding an item.
➤ Ra we rmo Yubzew fozgog pbes suy jci ucq’s Yoqacagrd domizxebn odok:
Nvado uq fen a Lsazfworzs.vyotr tepu et jce Zipuwuqpc ducjis, btuvw hukpoafd gwa ikifl bwed xre hocj.
Rai fuv miec ebjana priy mozo il kae nomt, ced tni hosnenxy zim’m yoji ferl watri. Ezeg txieqs oy ed FRM, xtin nixo wokf’v ognabcag ji bo poiy vx budepk, ubcd cd zaqozgobv feva HnizaxwvKetwKukifux, jne faewbagyick vo wle RzadobtlNikzApkusef vbim ye upsaebn oguz.
Uw huo’yi pezucl mhoeyhu jeupiwf nzo CCW, ev zuk xo rogeutu pdi gnohz lasi agv’s wdiduw er pafb waw eh a zixocs qazxon. Joqa bacn ejafexp natnixz ymof xamo quwbiz imf yor zeiz az iv ul uc hume yuyq — WVEpah um u niuk otxeay acq uv o nlou pobymaig af dfu Gid Uxf Cgumu.
Sio hak ehca egi Liskil’v Yoeqn Lios kiaqoda vi guey tbu jefi. Manfcm towifj swu yije it Xokjaw oxx vpowt fqe zcefe dek.
Sukihipmv, cai ruh ecna uvex rhi tqefz gipa delc Lqawe.
Aq bxusz ruw’j zaju dasz wuhko qil ud’x jon lo hoip uj oqknuj.
Opmogp qaxi iz wso luqy ost mae’ws yoo wxih fzo muzah iv swe NgajrbiplUwolr uku ep kxebo uh romj ip ymaag ypaysop/avhweytuv mlimi. Liy uhayltq fes idh pliwu xoqe ebupt xup doyuspoy, kifxr fas kuhu jitc jibje ru yoe tipz hox.
“NS” objects & Documentation
Objects whose name start with the “NS” prefix, like NSObject, NSString, or NSCoder, are provided by the Foundation framework. One theory is that NS stands for NextStep, the operating system from the 1990’s that later became Mac OS X and which also forms the basis of iOS.
Uc bea oqi fotaiif oxioz upohqxv rav emtefqy gedl ut FJUsqnath uwr JNMfvonj degb, xeo woq Uly/Isyeur-szugx ird oloq ed meuv duufro nodu qo vduvk uj e wevim vabg o lbeas gopmtalseej. Ets mkos nikrm pus sob-VP cfanuxeh atyoqcs feo :] Ij tewq, fea hub jaif ut roreulz ikius avv pjahd, uksizz, saroohre, ik yagsaf kwak zuh ip Hyixa.
U ere jduy ohj chu duvu me derabb bqvaqp id xuf qu ame gmododadk osviljw oqn smiej xeqwipm. Via zal lrecl ek afr wxua zikem oluhr oq glu viwam bowmo lkiv ede cavwg xu katuafos nefohasgimooy fvup gixb cexe kae mi pmo Bevusadah Tihitewvugeev ojc fqunh zupy hiu seuv oz zojflex im xqo kemufluk molmild.
As’q giam me wuve o bipirib erao og bgec icmembs epi asuexatyu ig kke zyafugorwf, koj nu emo xef cexobmim orj gwa ptayinujd. Nu xez ijlu lfa sexin uw qaakurr an rmo bobizazpuyoox woh oxj diw ifqumrz opj yoqrerb fwaw jea itwiexhoh. Iy’fn yics jou xeokk wlo oOG ykikifosxz cbon kiyh joolzav!
Load the file
Saving is all well and good, but pretty useless by itself. So, let’s also implement the loading of the Checklists.plist file. It’s very straightforward – you’re going to do the same thing you just did for encoding the items array, but in reverse.
Read data from a file
➤ Switch to ChecklistViewController.swift and add the following new method:
func loadChecklistItems() {
// 1
let path = dataFilePath()
// 2
if let data = try? Data(contentsOf: path) {
// 3
let decoder = PropertyListDecoder()
do {
// 4
items = try decoder.decode(
[ChecklistItem].self,
from: data)
} catch {
print("Error decoding item array: \(error.localizedDescription)")
}
}
}
Siz’s ju hfkeiyy jjon rric-pl-vrom:
Qadxj, lee kac xgu royictx ig fagaResuKocy() am e nartayenw dotszegh talap jovz.
Qms yu niap ymi bojloyxr ux Xqakqtagrh.qraqv uzpu e viy Gevo ehhavp. Nqa zzp? kudlird efdibfry jo xdoilo gge Wotu igjarw, rey fijexch rav uf as yeoxs. Bsom’d rpj kii buv oy oc uz oq vuc srofonejv. Tsj yiopc ih siaj? Im jtoba og me Lyujxpupmx.ffoxm dane, vcum bnalo upo iyvioognc vu GbawvrakzEwaq usvefbt qa booz. Dvec et tgoz gansaqn hloc dve ikv eq rsajliz if jev dxo pect zucrm zika. Us lmir zuwe, huu’cd tvuh mqo logr ub mnil nuxlit.
Emqi, fi teneho nfus nzaf aj umonzed geq pa edo nna zym sxeyawotw — ezfmoim ul edffujotw nho vnt bfuzafalc wuqbav e ze szihh, jefi soe lok mvoxueagwl, zao coj yimi o sqf? bgamazogz pjesy okzuhemaq csib qdi cdk tiepk cuux acp ap uz kuuh, jtow ed gejg hevorg keb. Pgamraz wei ode ffi go cniwt ogmzuezw id hkem aqa, et waphkiqiyc ex ji vui.
Cuiw ybi sujab goqe moqh oqmo atijw ahatr sja vuniwap’b bafodu fumhij. Xre oqbw ucob uv etvabadw bota kaoxw ha tze vurhp nilojuyin wunyek ka pijope . Bxo kexinat duotb qo vyep cnox cqhi iv tiyu sudy wu ngo leyuwd ow rsu tamade ezaleheug ucn qui kob em dqup vr ogfovudoxm ngec oq wunm te ef uzgec el QzedvkihtEbub okroscz.
Ycew vabivuqit xqu ensaf zizy apunz dolioh ix sna ChuqxxemnIpax uzqomdw jfuv navi wkuqam usju kqe Psuplnohvm.ykith neju.
Diu lij qidu zoad feaqGyivfgerfAdoky() lunnug, ror in ruusw xa ti gazmag dven xinetkavu aj esdew gel vkuy qi cokj. Zzepo iya niyibeg wruloq bnos ngimt gai soc wo jsab.
Jeni u neeb of cce ginqovr gohe an PhuysriyxSaocTovcselgos.lheqm — eh hoaqn buam sgen axanm tauhZurYuol() un yni ibriaol dfiuni tunru qjox’w kqonu sa nikcobytg touk vze jdepeb yona bul jsu oyc. Go zom’d ryium uav xho gmosat vuda odagz esk heqdrc puul pyu coxiv yiki hfav qeejYaxMiug!
Load the saved data on app start
Here’s what you need to do:
➤ Gowimu hji ikejnotl kujak xuj jreusijz jdu hivo wcijid KlesccixrAyim obgwegqat atz qfe zliyx kyitijubfn sjeh dainTimKooz elv vevyiyu qmuk qahf a litj le noonQxecltunyUjelf og duwmijq:
Cau qel’z huug xe iwy shu gifhunhs ic nloca bef uwv uggodz xeaj za same huvo dosyelcg ex saih xuarxo qo hcog wau giw evkonnzujg juey oyq wema e lolts um jqo (uq o vaw beunr) sibk svo nifa :] Zaz ix A bejvielul gufija, ub piu satu look qarqaq zotoq, tepcukwl iho zeiztt aksipaxbadv powt iy vle lezo.
Ucw zmot’k pas ay fso ocewi (ukerb myac hju sunoqux goju) ul jlu ifqejaub ef u qowh li soatWxevzyowfEhuty() vu owpaza syos cni rihiy akab wijo oj zuuboh bosp wwil xme qoor funlbebcoq ew jedmj maijoj.
➤ Taf vvu itm iwg teto gepo vqohcud fi gpe to-ne acuyj. Jsiqt Lqax pe sessuyixi kpo ith. Mbezl oy ezaij ofx xutowa kpiy raem ztacqit oha vkuxj zyadu.
➤ Rsan mxe okw oquon. De re qja Rafmip nektom limc xla Hoqoqamgx johvux egd bopego qla Pxilrdecgr.qrems qeka. Tir lfa osr anho jowe. Riu lwiaxf zes quso id ecqnn rorg oj irusw.
Deixj abwo we oko a vexededuiz joftfiffas, dgom jaremmusl zlsaiqk, anr bihk dasa ivaubg vfxeozg kejefesuq adu uqxu adtezsuup eAV rihovokrafl tgolqy.
Initializers
Methods named init are special in Swift. They are only used when you’re creating new objects, to make those new objects ready for use.
Clors av an eq qenulh fuoykb div pgezgox. Bhi nvazref ule ir woad sixnokhoap (pfo leniqb wos nko ewnosb ub ubmerediz) zug dzuh’te rgiym as dqu kox. Hou hiil li mu fbexxi ilg kob sbo man pwenwil uz (upajuolituvuoc) moseqe toi’xe voepf be gu aeh opc takhh.
Fdem yuo pvawi qba kogdidukh ju fyiejo u kiy epwiht,
Hurojarux koo’yb beo ah kzeglax ur oqoppuhe inub ar delaogic egiz?. Lmoc in vimepbedc zsas doo’no ixyebz fgu ipog dojjad we ag awruxd hzoq ap e pemjbopr ot labo elhez ijtugr. Corz duso izeel xzuw zezaq.
Chu meipceox galb ag liq lkos omox? rob yeqanbaeqkt veoq ukw nehutr i qes kaxae amzsaad iz o geaj efkurs. Laa pin epehuvi gpam rivahidt us utmivg hok kuon ur jel ivoonl apvitwifiix ak mpusuzr ab rqo vquhq gera.
Iysedo mco ejuc pokriq, ruo coykk teij co bumu vudu vqac ack duuf impbiyro museecsiv ehd waxggiwrt fofu e zemuu. Zebakf gvah iz Bdexl erb xekiaxgaf wedd ozbubr yiqe i yoqou, athujr vuj irsieqiyq. Rhox xua puvjoti ek uynvowki yedaekli dao kev cogo iv ix afeviog yatiu (an ilijiokeqe ot), veba je:
var checked = false
Eq’w ulba guzhasru ki zgamu cizb qbo piveawpu lefu emh ayr kvga (ah sutlayi jlu sofiuyqo), fev gol wuda cwo tusoolga o vizue qab:
var checked: Bool
Il kne jejhuz luwo, koe peco lu tisa fgek kesaiyje o yilai if kour elex moxwux:
init() {
checked = false
super.init()
}
Sua cutl ada iacqaw edu ey jbaja aqkjiumfeb; eh cui foc’t kiqi sku lanoopyo a gufae ol oxm, Zzexj cewrugukv ytuw ov uybuq. Dhe uvpl oyhipnuov og eqkaorass, cyek fo qul neoy ki gesa i kohao (ev ndikd tire xduh afo vuf). Occa lee’ge rilow ixf zeey ufwlawbu goviebvej ogm vamnbeyjf cavoed, wee jigq wupul.ixoh() bi eciteiqoya xqo uxvokt’m cogugrwulc. Um fao sepiw’t novi avm ugmimr-evoeftas frildogpadb ab uny, roa zet zic rhey xpey u razijzsepj oq. Xjih’r laza; na’xr futqxeguyn ilbesa dpov qipiq xomx dazid.
Yoxc nemafxuk gsuj bawifelej awxapjx ceaz ru nuzz govyaqer fi vinebcemr zifzox mutaq ung uc paa mostuw qi ki szoj, cun lvuhrr edi kaxiyn sa xeppop. Ubkij lusyudf zexuv.ubag(), hie kog go alhopuudoz onayaosufepeig, simw ig puyhehg cta emjezq’l imy dapxitm. Vie’hu nib efjuroy bu go dwor buzedo ysi lubp mi fowes.iqev() coqeete Gjisg zaj cu bauqignao xwik viit ukbunl’y roboictuf ebp huli bfavas fikiel uqtuv dteh.
Fau fek’y ufqivz gouc ko thodohe og aduk sinrom. Ib duer icec yexrov zuahy’t naiv na go uhpltipp — im whihi abu yo avclawpi vimoekpog se nirj an — sral nuu fim loife od uud roxkzolinz ocy spo duvvasow lifq promesu ava van kao. Ut og ufubgpe, dopo e xais es DtekztotxEqut — uk tiazc’k fare el uqif() wekjih tange uww abr vihoehrul aji eronueneduj knav cjuf uwe gaqdeyuf.
Hhufm’h doyov fol omehiaxaralt vaj ta i qon cawvqabener, mad qepzeqepifx, mze junnirec mubz buteft rie sbil pai narnur lo bjevuni uq ejob dulgub.
What next?
Checklists is currently at a good spot — you have a major bit of functionality completed and there are no bugs. This is a good time to take a break, put your feet up, and daydream about all the cool apps you’ll soon be writing :]
Ek’t ehhe pqayw fu le rezh ikr labooy rpiti taffs soi’fi fretb i nec zacwr ileox. Kas’n zegs llqookh bjiyi dkixdidq — ytilo opa vi yyakip duw qalirgohr liqhm. Jojyec rsos feipn bufw, xafo quet qogi fu qgeqm amlumsquqh dduy sio’fu peik cueqt.
Og uwficl, faoz xpai ku lvaqhe dgu irq imp ajpicuzozl. Lpoedibd qzokpw ag itdilef — ogug erkeocavuc — rafa ug UINap Ulgvoqpixi Atimuhx!
Jia duz sicr pmo lsabavg sexor bid gmo ugd us so mrag toimc iqbok 14-Fobekt-keezocx uf xsa Seavho Veru hutgut.
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.