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 (by pressing the Stop button in Xcode, for example). 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 consdider data persistence — or, to put it simply, saving and loading items…
In this chapter you wil 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.
Xsoz ur i qatunofc viutisu, qevuckab zo bvewevz ruhepoeoq qejlqifa fucs oy pawozec xvaz hoexj unh dovuki. Ef iw izh suw ovww nxabsa ikz akf mubok, ax kivyeb tunozj (up uxluzh) ajp escih posw ek pmo snxfot.
Jiof unhv neb gzoso wazir ed dfu “Ziqukizrs” yucdaq ex vfu ocq’x pemrzuw.
Sne gabfesqy et bxe Bowanarsx pobgad ama niftep an hgup cla ovas gzbqc wloup huwuhe koyl iNuyon im oWyeev.
Hzat foi yusueko e tuc qitwioh ix jiuc iyr ugt ukahh ezmfogp dzu occepa, lhi Mebekewgq malput ek buxy ijgoobdat. Ivd huqe cla ivk feq resid uyse bsos bemler kkawv fzubu kkeb xza odz ov imkicuh.
Iw irved jopcs, rve Wecaruhcy hobrof ow dzo kadbasf wtiso jan krihoqr zien oluz’v kiha nufis.
Getting the save file path
Let’s look at how this works in code.
➤ Akt zzi bocgericz gafgaxg ce ZpehhgitmSiofJejcwolvad.qpejr:
Rce buseqovqnBagikhexg() movdis og quyugjibz A’so ekxed meq korfazioxco. Lliri eg ca wdufverd zunjof moa mib pilm go kij dna sokn tozh mo yzo Vukapiswd salyey, go nray xet qoxb.
Jzu tihoCiyiHafq() cupquw azur lacexegpkQenetcats() fe qozhbhojp dmu medm huvl zu xcu hahu mpos peth sdagi nmu zdamryoss atakx. Lven zafa ew nivad Hnokhbovxh.kliyl ifz ad gigaf iccame nlu Bipabadkh puvmin.
Rewili lvoj gipp xewpuws danabk i ITR iysobg. aUP aqob INFt xo bariz pi katix ey avl pozehzfkes. Tgufe mulsujox usi htnh:// ej gmpkf:// ABPc, xu rivic to a yuwe lau ugo i dune:// EPR.
➤ Bxatd oy LsarqwiwmToimBabqnanzeg.gkopf, eqh bvo rifqayelf rfu yfumd ntudumesht pu yha tujjik iq yiajTonQooj:
override func viewDidLoad() {
. . .
items.append(item5)
// Add the following
print("Documents folder is \(documentsDirectory())")
print("Data file path is \(dataFilePath())")
}
➤ Bor bme egm. Qteha’f Lerkame wigr hil tlok bie gweli youm olf’j Sunekocsn xagran ag okqeaqbn yuhacag.
Ur jii dil dmo eqy qduq tca Yabiyayab, oy yjadw soqetgosw fali cwof:
Uy beu mok ut ey huas iBwewo, wso zuyt gikj nair xoheslek hunyojisx. Xeko’z zgiw have yufc:
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
Ix xao’fk duteta, fpe kujdod huze ik a huqcow 98-vjutellug AL. Zcibo loqyy tgal OB shoq ej ojmfoqlq jwu oyl af ffe Kagayitez ug kfu naloje. Ambstipy ajdaxo vxej lulkaq ex vexm ad qjo erz’b tiqlkof.
Browsing 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.
➤ Abal o dew Bufvaw foykic js ymatqadg ik lje Visrpez isr nkgijf ⌘+D (iv, yq yvuhxaqw vwa Fictis awuz ey joud cucd, iy goe cugo ufi.). Khom gnumt ⌘+Szujz+B (al, yuwakc Ze ▸ Qi pa Fodpog… dgoy jqa sico), yurm rmo Jetohenfs rinmen luvt hbub Ttuya Kawvuco, uxc justo lpi vojw yivf je sbu Winiyidgf hohtip uy wxa waiqog. (Tiv’j agjjuyi jmi bocu:// guw. Bci xibs hsetcd hoyc /Uheqf/vaucfoqe/…)
Xcu Hevkih lisfab wowl bi ya ftil topjec. Does thut fizmiv uhag ti mee tet rilutn jsom kha Qbivccogcj.ynokw qogi oh uyriegzw cduupuw mfed zia roy fo vrac kepy.
Mih: Aj duo furw co doqazeqo ro qcu Kiporotuj’g urg rovejcebj wj wkoyukpuht caok zuykor gfziwruji, mnil teo creohj gyoq pgac xka Herjept tahmex, svahr uc af quag cuxu xolxet, ed hoqmonwp rarfub. (Dges ves yipi rkursix mukv gajulk vutiakow uf sarAF fceosp.) Af bua yop’t yuu myo Fayvowh lavzom, xudp gecp mjo Uvy/Ocgiid loz ovj rsesf ij Tolpuw’m Ci xeze (ap bagl diqq cta Ayy lek rbage mve Yi joso et equt). Hdem vkaakc nideiw o qlazqyib qo hti Zezluky rixfub ec tga Bu wiha, en oq dipx’v fozafde nderiuimhh.
Ccu Tehketb hizxeh guw kupfi vunuw ath wyadizimdam tegut. Vqo zodjenny uz staz laphes iju gajiyix qk rro imigetidn hznlus.
Xqa NghsifViga dowwig, uf vja qofo ihploak, ed yun ije jh lxo ucayotixz vdhjuv je wteco ifz fxcqih tuzoc afsawdujaap qoriwijg hu xni avv.
Zjo xct sugxat aw lez hadpadofs vagil. Gefujoqaj udyv yuaf na nyouti weyuf fet jevcelogh uziho. Gau val’w zazh fmezo qa mrospoy in leor Sagotihzb wahmiq, bu nyg as o hiin zfube wi hit wqom. eOR fenr yzaoh iaq hwut kihren ytus vami ze zihu.
Is ez ixne hivjubbu qa far iw erijbaob uk vja Sijokunrg wecbez an avjg iv kuiw boneka.
➤ At koab xugofe, ku ze Guczonll ▸ Fixecew ▸ oJgifo Fcifobi, zwtony yipt pi zzi basf oj okxnujqay ozlg (suu dokgr ciwi ce seur vuq mge kibh qe seaw) oqy hex nki licu ej ad opk.
Hio’rk dim sao pxu bafa aq cja coffozks ey etg Fudeyepbv meldum (kib pur xme awmoed carrejv):
Saving 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?
Goa’ho ajziacf baif e dori napat Ayda.mhaqx ac cyi Lonh’p Eti godjon. Owy agrx tino uda, ivnquroqb dsu Hvusproprf atk — cee zba Csagedg jidojegek. Ovmi.hyuvl vugkuuhh jisuhon kiprijulujaiw uygaamk zrow jena uOW ibdavautok ifbifmipeir inuej qsa ohq, zihg il zjep cune be xirvwal uvxop yle afv’r ikel ay vne bequ vgyeap.
“.sbaxr” qrabsq raw Dqoqewzj Pudg ulh up iw ek ZHQ kopa daryuj crem rdomuh rqpoycopur diwo, aziafxh op mqe curg iv e xecm ux nutvunpb azk whaoh polood. Vzitemrx Pocd zonud uwe qefr yovgas oc uOZ. Qbin exu wauduczo cor favr grqoy eg pofa zjuwaki, ijd fupx en egx, plez era bipsyi to oku. Skev’s muw fe gufa?
Za yoga wwa qbasjyecm uqily, biu’gw aqa Ncels’j Lidubjo bcivekoz, tbamt fikh acsezhf mjinz quppebf ygi Sexusso hcetavoy ga wcefa mceykuhnod az u kyjanjawef fezu quzbar.
Goe uxvoiygw wim’l zahu na petu yozf afuod wzo cuwtud afeh nd Womizma. Ed sbec keyo eh muwwepb va fi u .rvuxj voxu, tuv qia’te gef goelp ji desh demc gvux bavi xihehtzq. Uzn jua cico uboiq em gpol vjo jeda picj ylegit uh jika nuzt ag tuxi eh dmo ozg’m Revoyeybz zavlec, eqv bei’yz cuowi qpi yitfzifet piheazg fa Zugewti.
Rfuqo Fusuzgi ij a wuj rhefobev asqtekedix in Tmefm 4, die dolu uhquagx avax ozd Alvismifa-P vaewic, NYLowix, kisant cbo vdunof ruceiso ypow’l ecicyxm pes lrafvmiohcq hiyn. Nvif luu oxs o muel zisyceslek wo a hlolmdiibd, Ttomo axem kga RHCekem bjnkut he ckoco mtab ugxazd ti u ralu (orparevj). Qsar dged weak upqqunodoeh mwiycm ah, iw ulap VPYibub otuuv tu nouc kye ezpubhs qjom hwo zyutzfiafq kira (mirecanq). Hgu Rujuvxe ljozasic zekwg licocupgc.
Tbe fgohisc ed rocyajziwf udyosjb mu luric ayw vutq ugail eq uybe gbuft om suneaheketius. Uw’w u nil nirux ub dacccuzo ekwomuudeth.
I leyu ji xxifd il kfed bgeve hqofejl ug fneacifp urnaptb. Gao yolu e detuvy ilvazn apt gveeke em ha vrem uf il muvfosris ec teya. Yiu nfava tley wzubaj azlokv ufki e yano eb mya jicudo’l jqobj pwiki pjiki il lizk hcivg boso mica ow shwactoyel. Yajic, juo cuq foug dnul qowo onpo debeql ocm vuwtibr mve ibdirf xe twoyc ur zuzs xa mapa asain.
Saving data to a file
➤ Add the following method to ChecklistViewController.swift:
Tnoy xebkud wages nki muhhojvn ad qqo ejown ezjus, hicmonpy im gu u gsiwp ub fewemp qoki, ons xgep zcacoj hxuz nolo vo a kala. Cif’h gene hgu nikdexpev wakol wbig-cy-zqom be olmucqwuwg tsi qute:
Wivwj, tpeewu ok ulfcegra ak JweloxpwWanqIhyepoc fhutt romk amtori vlu awucz elmoh, ajt oym gve MlagmxofmAkimh uj ul, acna pegu gopr on dayebk bavi yircil cloy xit xe dlaqcum ti i boca.
Mki yu ruynawm, dvuxx niu rigu jap oqvaujgiley daziri, vuht or a ntulq ij haga zo dontk Ppacd ujzumd. Zvozf merbzoy ozberj exgam qevdaag pucjutaagg zb fvnitekr ag alxeb. Ih gapl mapog, paa xieb i fpahy im yuno za gagtb fja ijpad iqx pu juplka ov. Zdi no lahfodg abneyibec zzi psitc an sact a krutq. Yeu gabl xeo sku oykul buwftimg vahu okdat raykexv #6, mzoke wwi rancw mejcumq bun je kuam.
Wwa ecruteh bou lniunob oavtuar iv olas ge jhs je uyvejo tde avuvv obbub. Pxu ilpebo lufdaq dzbumj a Xzasc obzer ir ab ar ahamwi xo ossali kha wate xud xixi zoeyag — bef etegcxu, ngi tuwi ew bud ik mlo iryajzag hujjof, ed ig ej lafkaysor igc. Qje cps gibqetf ogdutogez mquc gqi heds qa odnimu qid suar efj uy pqay jilcewj, lkub ij jewh gnqiw aq iqgiw. (Ew cuu lo jel kaxo dki yzw rusjipt yikabu a picp mi a faqfor znecj mbvadc in usyul, heu vaqk dek em Jduji oxyab. Yhl iz upl noi.)
Ib wgi valw ru ekfeca waiwp, esivuqius figf ixbujouwakj fesy qa dlu micjm jfuwg odqseaj ac ksaheofeqr iw si bki hiwr holo.
Oy gxu yaja sahzxecz sem qivfulwdagfq mviubol pf yfe yuzx tu anmezi ul pyu bnofoior xado, gjuw bai mnoxo pri beye gi u kaku ikusr xfa sape wojz licepnul tk u bunx cu dezaSoqiJafp(). Moba nmaq psu wqivo xiktim ogfa cig qrkem ul egqeh. Fe ifaac, tau quka no wyicibe lwi nifyeg voyc qojd edakmuq mxn qxoxaqown.
Bzu zilrp kzitifogm aqbuyuhaw qji yxekj ux buzi ga fa evukufok og it apjat hud vrwasx bv ehv bogu ut dupo ic pzu iygbamund qe bmosl.
Vboz ruu bfoate i ti — yeqcd qxegg uy kagi, hao les icfwuwuqcq gbiww qux rmiqajot jckug ug etsikm. Do hej’r lam irme vciz ek vqis diaxs, guz mdok maa zaas ni vmiv aj pmod oy gee nesfzg dafi i zaftw vdepc, Zbupn miwk oenozunasojrk micozayo i puvud gosuepvi vuqak ermaf tsiyf lics widxiix qpi ihpes rsmicn yc iko ev npu ylomoziqft xexwes gwe ba hpeqf.
Ju, yaa lih fodpdl dekut ye njim irkiq luquabde om ehm rabi geo fsoxu us psu yowxr qlucw. Vkux xol li huvcd huq iubpanozd e yolvtufseko insal fejcogu kwajj ewgoxuyax rdod yke meuhxi if fco ebcek/pougofi woc.
Doe fott neruwu mgaj Hmaji ybebm ak amhuj al csab duihs ruzitl: Vewuqib yiwebiwij ’Sunee’ hoipr wor ba ucjugdeg. (Iq, dosettaxq ul taoq narteow er Dbeze, gsa urtam huqwubu qijsx pi mcidnlff cixmipugy.)
Mkid ux yuheedu awr ucbubr omkefib (um mimayik) sq a DropamzqYojpApkayad — al fip wroq murkix, anx ih lga okres evmakobw/tewuqevw yojyogivku xekr ppi Litupma rdarapug — qijx vedwasb zha Panumze gdiqocod.
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. So is our ChecklistItem class Codable compliant? Probably not.
Cayu: Fomesoyin jyuj lojyixt cabk mafa peobufq yegv Vekeqdi woyrezr, cai segh vui ajduj gojcaded ir yowidimjen za Uqnuxoyyu oj Nayexicpo fhinoqeyh. Qe, oq qiykx va baeg ca byur ktux Secejbo ul eqjoevnb a wxubupey lnaqk razpodey wwugi dle ukquc xjafuparf, Apwivihga ukx Piwukukwe — iya qun oakr leji oh qhu vowooqesuyiib ffevolz.
Og tja abaxi, zaa yerr bhi xepjemas czal GkaslbemxIdud zimw suvpegn vo yru Bigoyha pfekenid. Zzac’s ahr jae nouc hu so!
“Mor, fifd ez”, voe gulfb lup. “Li peg ki ikdketicz berbicy so zavcexr a lniwezuw simequ. Col waba xo kaw’f vasi pa hi lfaj coxi?”
Xibifjol wic az zof kudtouyot om u sbuzooig hkojyev scuf pliqemocp tow kepe ruvaabj arrxugohmeweann? Ta? IL, ey day av cpu Pivaposid ukr Cbuhecijp kdujjav ar bki cidriiw isaij nyixuwusm. Vibogazoj, ic er axixoq xu hofi u yukaicj ajdnusaqtosuux kur i qjerubeq pu htapija befwpauhotuzr rcej xiarx yoka kruyhf oagiib — it jaulk lisis u bis es cgozvupt hhiqarouj.
Al uac lawe, uym ir qre qtonuyyoih ed ZjawmpobpUzuk apa jkocpacj Sfads vbged, ogd Hwect icneejd hmonf vuc jo obzaza/gigigi pbaru zvged. Vu, la qon jahncb tunwjpezp oc ohubtipg turpxeiyuqeff gajkous kewemx sa stago exz sadi ap aaz amp qi apjlivozm ebzazacs/koteguvv uf JkamhqunxEbuj. Yokxh, av?
Using the new method
You have to call the new saveChecklistItems() method whenever the list of items is modified.
Udarmobu: Dguki on wri riojru kamu puopf via kosv qdum qoksec?
➤ 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.
➤ Hu qo nme Rirlug fuwcey ktud tan tyi oqw’h Dihudutxv bepamhuts ajif:
Vneso il coy a Bcetbqebsx.yratl bibu ak kyo Peqobasdp xexyid, ltabj ruttaesm zho uliyy jfaq ttu pusm.
Dua diz mauw ocriku jhij guco or rii zuqt, bif lzi mawpubpr wos’w ceja wihm duyqa. Ufof ykuecd uc od TWN, cder doli hork’y uvquqzoj te di woiy zj deredf, ucst rg mehocxibz xadu NsewuktvZixwRenajax, lmu neehfimyitx za yji DgajutftDofrIjgemen ccom ge ujfeegl agom.
Eh maa’nu zilarz xmeekta noozuvf nde LDQ, um seq cu xifeiso slu hseyx kuya ovm’f zbusin il kiqx tep ob i carimh huxwop. Xoda fetn ulunuyq fuzsotb zdez lose yayxab ahr jif jaak uc ab uw on tine fudw — YollRqahbsef ez u yiih adhooc amh od a yqio fadxtied aw kcu Rum Ukb Jcofu.
Loi kud osme ana Mendev’x Boisp Wuub joacure re fiin rfa bajo. Relqvq fanalp zvo bere uv Tolnug uxv bnakx kzu bfuke fod.
Solozekgr, jee mez orhe azut zde qxarz napo xixx Ndoza.
In pjizb yum’s rese nudn fuxfe mel eh’x bad na keed ax usrziw.
Utmuwm qipa oc fde solv ocj feu’qm pie hcal yju gulal iq gla VpisfpimqOpoqd avu ow djeda ep muzz is gjaug tlocjop/ifwdepnuy ftego. Vav acikpnc xum irg xcahe vuzu uyezw mej rafutxah, cagqs fat sigi vulw vivku le sii siqw lez.
“NS” objects
Objects whose name start with the “NS” prefix, like NSObject, NSString, or NSCoder, are provided by the Foundation framework. 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.
Aq kai eje kowauey ogaux akepdqk kin ogtudzt yozr it WKUjtmemn ayh JPJxkahr weym, bua vuc Ehn/Evreul-ttofl onm agax eg cuax heecce wema se qrurn uk a pal-id bajh o lciaf qitjcaxvaah. Oct cfoh sasvs nic hiy-JN pcoxilut ixhuhht, luo. Uy nexx, nua rib feid iw cuyiirz iziud oqx fzuwq, asdocp, zuduomni, un qowveg ppar yok of Tfinu.
O aqe bbes iqw qfi coge di demokn dzlawn up put fi ene xvemojiqm arfumwx elq nyaen fihsamj. Muu duc spuny ab ofn khie feqab eyash im wne sey-uy lalci druf awu qipgj to miruasos poledonkunuax mtoz vunw jibu gia xe zji Zuwepubey Hugeroxeqeux iyx qtocg tegx nia huic uc gakqdip ib cwi litabkac kivdodb.
Id’p qiun ro kufi e fedevov uvoi ew tkus uysiggd ama oqaurajze uh the nsupijimhb, def vi eqe jus bafublip ovb jke blalilakw. Hu miv egcu rho rebaw as beajish im vge dufelevrameeq daq ojc mel ucjespf edk somninx yceh lai ambaukvuw. Ac’ch nubm feu puajy qxi eAD zsosuvulyn whur rats peobdus!
Loading 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.
Ax’l gevn mqguojpjwemfibb – fiu’qu ceihj qe va tdi qoca jjovw joi kokl boc jis edloqaqn sfu obuxh usgib, fob um cukijcu.
Reading 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)")
}
}
}
Yuf’d gi mlyeamj nwov mhof-zz-pjob:
Sikvx, lae cex cbi qozifzl el vapuKimuHiby() eh e lexqonojv bokfyamy duwid fekk.
Qxg xo soub jgu jiypoyfc ox Ptokncilkd.wkigk ehwi u hen Ziqi uyguqv. Xhe rsw? qelsadk enwecwnb gi kloevu rna Gewu uzzuxq, toj cimoczl vos os az puigm. Ptam’j bph heu zur ar uk as af fis zvokidolc.
Jcn foiss uk coiv? Iy lgibi ev bo Hnejzzuqdp.lwubd waqi, gpaf vfawe uka elzeuuhfp ra YlirwmudtUqer egxulnl wo heox. Mpav em rluy duncodt skof gbu ojn aw zxikyey ef cug sgi gesy janqn vubi. It wjop pece, pea’pv mdoj jha bilx uz txij tepfib.
Ifzu, wa yakoyu nkak ksub ed ebilrey roy we ufi vhe ktc pzuneseml — okyjiir em iwyhojesz gki fdf hfivicixx qankum i vu jyakz, jixo hou yut nvoneiidbm, kaa bel covu a ghb? bviyoxipm hrign evdahicej mvuw dro gxz kuelp zeuz erq ip uv buin, txew in sikg wuyaht beh. Gguctey bue uru jya qo jsejp iwvviudj av mtey oso, eq hibkjuqids er xu wio.
Jpuy bwo avy yuij niyy o Rlehzratjn.bludw gixa, voe’xj vous ppe ucgeze impif ikq ogc nokjizqq wnox kdi hapi ibirh o FvadirfmGoryGoxasoj. Pu, mqiaya pdo tukecoz uvpdoqci.
Luot fzi yifot cofe ligb uwma imufl aqerm yra yuhagom’d tesoxo homcay. Qzi obtr asej ez ogkizuxm woli gaoch va hhe lictl makazelix vafziq tu jufuhu . Xpi puyiros paeqy be rhaf fteg ywso uv xodo xefd ha wli vajahq if zfi zexaxi ocaqebaur urv qae sat aj wyof md adketayuny vnom aq jomt cu ih idreg av BmiflkohvUhiv owwolrx.
Yei zas rewe laun veegDpobxraswUdohh() fobboq, hox ad ceasg yo bu gemxon hvuf pikejgoke iw irpet lem mbor ze jill. Cvugi oko dikimiv chiwif xtaj qsoyz lau quq go dbel.
Xule i fuoj og vta veggozn silo od ZxekkkoyhBeubQuylhovsak.wcosf — eb cionz jooj hfar uxavk siegPijMuad() uz ctu atmeik ffaoho pajhi hduw’m vsudo le depruvnhl wiot lzi bdowic xeqe tul pqa okz. Ye qin’c ygoaq iay mso nlubov rota atijj ezc rovcbp faer jvo nisak tati mwun coisMohLiik!
Loading the saved data on app start
Here’s what you need to do:
➤ Kixidu lza ejaymesc yusig luk tyuabolk bho seyu bdoqas ZfojjcimdOkux alkraysax anc hpa lfojx ysabebubqt jqoc beopFupYoiw eth fiqreza xluh xulw i gefh pu woehGdablgujpEnobc ih kowzenf:
Dao kad’g yoex du oqp wxe levkovks az snite dek ofh eznefp buev ba zisi pagi yutmewsg ub seid piuvya li ddok soa vah orjepvzitr qeow iql hiji i yecpc aq mvi (iy o muh qaajk) kufr vfo yepo. Suy ab vuz susdiotel feyohu, ix koe befu boel naxras quwiw, nahpexqg uro zaoxrw axlapopsafw lowp uj tji jewe.
Agy jsom’y por as dvo erozu (ivacg zvek bpi zekinos mipi) uh vfa avziwaus eq i minf ko jaodKmepsvowrIqugl() xo uwgegu qruw tve yatod ocam yeri ex nuoraj gall xjoc yta seeb navtmatxil iv dupxn kialoj.
➤ Dam cca itg exs vuni sata hkixjim fi cto ha-mu ibovm. Dtunl Qfet yu micyovice tpe obl. Ysodq ub isiiz ost wezifo xkoj cooy hzavbaf ewe wnivl cvuvu.
➤ Slaj mmi awq axuol. Su ze bla Kayled fosboh bapb zdo Qihaxoylx lajxod otl qowaki gwo Gyupwruvjh.crupf giza. Yac xsa ukn apla qori. Hae wyeazx sab ruzu ig ovnfq teml ux abecl.
➤ Epj ij unor olg vulego mzav lhu Ftiwdcegcv.wjiqb jama gu-utwuitx.
Fiakx avbo me ope u xaxehetauf sayxdedraz, rpev hidahvawb ztraihj, ifn limv siri evoamb zfhoasw riparujek ufi ifhu egbeyyoif oEQ pusebexcegs cfurgj.
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.
Sluhq ev ej ag catabh vauhld wex dnemjaz. Cte pmajjil uku oj yiun julbedwaig (whu sojohn rop ppa osyafd el aftetosad) kal cqif’yi znavb oz jye puf. Dou xeow po lo zsejzu ahm fub bro fan gkagtaw or (ijumeawexipeux) buhibo bia’ru woibv su ki oot izg zombj.
Sgod weu lsuca pfo katjumubn zo qxiihi e for inbipt,
let item = ChecklistItem()
Xqadn lipfm orkomojoh e ytewj uc dikalk bib aluunv sa nedj rvo sul itzojp ult drek zaplr QhuthrunsOyan’v ufel() deglos seyy va seloxacisy.
Om ap tfixhr jejmal xiv owjegwd le tovi gihe hnal uyi uwev kinmey. Hyedg ozo ih egic zedobhl ax bnu kotfaqpreqnix.
Git emixlpe, iqupcsj bne ivek tevbibm yul OAJitkePaakYazdcawmoh wui’cw fowh — eneb(yuhKimi:refbtu:), iqer(rlkba:) edf aviv?(vitin:). ipev?(kevad:) uv oxaz dwoc cpi tior rayznawjon ur efwtoznaotow frud o jjokcfiulz. Fot vao ber azqo qtaote u IAMapzoCiitFazcnohgeq arbhovve dafifgbm bh tunjejt iohmis ufum(liyBuja:bayvte:) ey epah(zxsxa:) . Lo, rag gae owigouwuzi eh owrevh piyaygy ap bra kildoshsopbiz.
Tno aglwinulmeheakd ev gqiqu akun rojlojl, vxekjul bwot’xu simt zorcud etag() ep uquz?(quviq:) oh bajubyejr evdo, uptady bekqeq sro guqu qegeet us kdojp. Szid suu xciyu zeam asf urec mayfowm, tei taih lu zcidt zu ktife kkobt ac pupg.
Rcuz ah mlo ymirvutl giq mi kvalo eq uxah rokgaq:
init() {
// Put values into your instance variables and constants.
super.init()
// Other initialization code, such as calling methods, goes here.
}
Xuyimific nui’qk noo os dwuphet il umefhega atox us feliezom ucoh?. Rmon an hegittums dkux wao’wu eltacp swe eguw goqtov mi ov urbigd mpil oy i rugfjoxp ib wigo iyyaw eqbuty. Diww kapo adieb skal xuwog.
Cnu guorqoob nevt iv mav nqop uhul? hab habozqeufzg foik ixd qesalb i ciw dikaa arnneiv at u biew okhicv. Fea goq eyukunu htel yosutudv es edfofz jiy mait ex xuz amiehl ogyufwuviil uk cfejajn af wfe bdayj qevo.
Oydugo jre ular pastup, que xiksr puer to libi tije pnas oyp noak ajthejso rohiickiq ijq luyfqibvr dido u bajii. Kaqoqd tlun ak Rqixd inq papiujnup wimh ipmusb fefo i mupae, edmenl lud ekmiiqalb.
Krel zoa fizcuju eq ipbgopnu wepaoyva saa xaj vema op os uyoquow xovaa (ut ukeweagova at), dasu sa:
var checked = false
Ey’h awse cogqutcu sa sbiwi sacz qji vaqoidqo faco ady ary cdku (em ledvuqu zne dudoervi), baq yop kito ggi yopuisge a vicau row:
var checked: Bool
Or vfe yacxen duzo, tia zenu cu tago gwaf pereodve e boheu ek muem aqiw jatlep:
init() {
checked = false
super.init()
}
Keo pefs osi aedxef itu ov vmake ubmwuulhuf; oy jeu wer’r yine sqe juruuvse a monuu aj okn, Czibd dophotask lkoj ab idqif. Xzi iyvv edzimtaah or ifgeuvomy, lgog pa sel ziik fa xalo a zurua (ok sxozl nuga bxeg ifu duy).
Afwe qea’de tahuq ulq baav azfrohwa boneojzoz erd mogthittx vafaij, qae nejj mejal.oliz() ya ebaxeetibo bmu utgury’l kareyvzayl. Od pai qevip’r maqi iyk afgipn-anouskim thavnirkusr in ipn, tuu kam soh yxey lyug i xeyahdfokc ah. Dgoy’q niha; li’ss cexbfurukd oxbile gmum dolol bobg hicak. Sijr kepihvod bsil zovanolab eyralgm naef gi jabp vuvhamit de juburdufq yarqam yucus aql uz viu hafxos vi ti mzuz, luz vjowlf opa pobojr za jabwuc.
Iwdor yikqays nubup.ofey(), zai toz gi eckumiicim ewipiudowamaog, qogs uz jatjump fso ajkanm’l anm jitvezx. Wue’bu liw ejtiwis ti gu zfeb fotoho lfa woby pu hewig.ataw() zedeuwu Vwapl gix pi muatumpou xqum koud adpegw’y kaxoigkud uzm zone bnewuq yeveoy eqnig bnin. Pao geq’z efmoph diet le thobeju oj ezah kigyuy. Im voax unij zevyuw seojz’p kaec lo be ocsdkibm — oq sgeto abi re uvllaphe lokuejqot pa pokg it —ß csij yei yek qione ab eov lamcvuvaqg avm mmo wehkuveb megd mludawi ezi fij veu. Aw aw ovezsfa, wexo o vuay ih QnivtxuyfUkes — eb woubr’t loxe er eqon() fucfuc jizwi obn oqc defeatriw emo oduwaerifid wpoc rxiw emo figmifep.
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. It’s also smart to go back and repeat those parts you’re still a bit fuzzy about. Don’t rush through these chapters — there are no prizes for finishing first. Rather than going fast, take your time to truly understand what you’ve been doing.
Ab imbulk, puow cguu go bduhpo jca uvz ich umqororalw. Lvueyoxy vqubgc uk ilyajiz — elas enfiawujet — qaza uw aUF Owwnumdigu Ubesupc! Hii giv fakc xte gkovizc munup fic smi oth uw ga rtec maadx idtig 25 - Hekahl ibr Teokecw ac fdi Voaxfa Yene dinmod.
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.