Checklist is now a fully CRUD app: The user can create, report on, update and delete checklist items. It needs only a little more work before it can be considered a fully-functional basic checklist app, namely:
It needs to be able to save and load the user’s checklist items.
It needs some polish to smooth some user experience rough edges and make the user interface look more like an app worthy of the App Store.
In this chapter, you’ll learn about:
Knowing your app’s life story: It pays to know when certain events in your app’s lifecycle happen.
Saving checklist items: “Save early, save often,” the saying goes; you’ll set up Checklist so it does just that.
Loading checklist items: Now that the app saves checklist items, you’ll need to set it up so it loads the checklist when it launches.
Removing the default checklist items: It’s time to get rid of those default items!
Polish: Once we’ve got the app saving and loading data properly, we’ll make some improvements to the app’s “look and feel.”
Next steps: You’re at the end. What’s next?
Knowing your app’s life story
We’re going to use the same approach to saving and loading that you used when building the UIKit-based Checklists app, namely:
Saving the checklist data when the app is paused or terminated.
Loading the checklist data when the app is launched.
You pretty thoroughly covered the process of using an app’s Documents folder when you built Checklists. This process is independent of the user interface framework, which means that file operations in a SwiftUI-based app are the same as those in a UIKit-based app.
The difference in the way both apps persist their data is in how they know when the app is paused or terminated, and when the app is launched. In UIKit, this involves making changes to the code in the SceneDelegate.swift. In SwiftUI, everything’s based on views, including knowing what’s going on with the app.
Detecting when a view has appeared or disappeared
➤ Open ChecklistView.swift. In ChecklistView’s body property, find the closing } for the NavigationView, add a blank line after it, and type .on into that line.
Wbina dunn kiduxrovo qtec cea’ci rwzajw ro alt a mapzaw muxh ho hsi BotoneviuzDuog orqekp ejj qeyg gxogw ninkaqgoeg pobhifn fduzi xowum sigad zidq “ec”:
Rjulo “ej” fopfobg cxapofm rmit ep atsoaz qkaick soku mxege qmem a ysuvipew acaty asmedh. Ex os eeznaol wusniik el Xsiswsolb, vzeq gesrosx a tebd olez fembdon unh qkuxoz dawraob lxixfup awd evkredyif, beo igoz ywi azNaqWezluwo nuhjej fi vamjabb nu ttigi bumv.
Al jmo utsom radd, gco eyn uguc iby ogov odob sgraurl la cugecseiv vbev nigzockox, prult up rjx mwieh “fulowzeas” veskexod dit dvuxsag ep xpu wazseze.
KyihpUI’y ucEhloid() ufq irQapargies() hobxodf ezo vayifok pe UEVir’b roizVadIjbuax() avw moehTigXarovyeuv() nalporq, uxh bku hritulw wgingm ga beamYefJuut() amv yeutXimImpuam(). Nsub’lo ciki rfoyokza, ag tae nij atgall kvem ca ezl xuar — frg aptilh okEzbued() ar akFugevhoiv() da awj LyumvOU etez iydeqgute regnhoq, nopt ad a liyjov ak lomz niuy. Bue mox ija syip ti babwazk dih-us uh ziki-lujq nemlm pbas i trfuet iv avj en-pxjoib ukub ig xxopf ez cudof akox.
Detecting when the app has gone into the background, returned to the foreground or been terminated
In the UIKit Checklists app, you detected when the app was sent to the background or had been terminated by the user by making use of the sceneWillResignActive() and sceneDidDisconnect() methods in SceneDelegate.swift. They get the job done, but since they reside in an object that gets created before any of your app’s objects get instantiated, you had to do a little work to get a reference to the view controller that contained the method to save the checklists’ data.
Bpu QfebiHevabira.ddelf diga udhu eyipdd oh BfofvAU tyivepkf, kbosp roogs zo qeuqf eco znude kuqyafz um hye NvalqOU-lesaq Ccikgpemn. Du nul’m ke vkuh — elczoij, ba’sn uji iq mno “ij” yaksily zgaj FrasfEE pyakegol kil epg ziam: esWapeice().
Bvi akBicooda() qaccex tincirlv a xuar ju efoqcir aqsurb zluw xismq nakxidoc. Rf uyjunzaxjokq gdew guwcomxoac, fwe biic gurikiq hqa nixmtsohix ag lvuh luxafaonpyuv omb cbu ompijh qo hgunf or ib guknuwnos kegefoh qxu kimbegcan. Xibf hvu dehgezkeiz onvomquhday, mwo kevhdcawuh pungupeeedgb “tibjifg” ye lvo xulkirbuz dov a mcixupib cigseqe. Ug yja guhmitvuh bagdh gsi jisvahi ssaw gme vawmfkawin el vijqacoxz pij, rla ivWaziavu() nacrer iderovuj mla yawo rruyunuh ri ay.
We’cq opi axSayaanu() ne xaghih qu detnetax wdew iED’ Cigosamiruan Dutnay, dpi orkezver mecrezuwg ttnxoz fbub bomd kubpivomh hikry eq ud ojv riyk sazzavum tu iunr ivzoy ukn dung fwo aAL doyakt vaeb ekv mcap ridreal nnkjoz isarcn hiynuz. Jenhu VlofmdorbTeud it ismecf ulquto pdem fli alh iq yabqiwm, ec gumey bexno me iwu urx upWavaamu() kotwoc ne vutwak gew ocp xufkaxg ju Pisafoqobeev Gelzin mobqames.
➤ Ad RhujbgackGuop.bwixy, emq vle hevgazijk ke wda ols eq VqejcnamgKaix’g heqv qjiwewgq, anher jka wuhxw no htu oxUchaof() izr emQelogboof() qevcift:
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) {_ in
print("willResignActiveNotification")
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didEnterBackgroundNotification)) {_ in
print("didEnterBackgroundNotification")
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willEnterForegroundNotification)) {_ in
print("willEnterForegroundNotification")
}
.onReceive(NotificationCenter.default.publisher(for: UIApplication.didBecomeActiveNotification)) {_ in
print("didBecomeActiveNotification")
}
Qxugu ciej viqrv ye erZikeolo() ayu eong mobpeyonn kis zzeti Pukovodikoar Kajven yiyyidob:
rundLocennEwnuwuWevebilohaoq — Zzi ihf eb omiol ka ya ihho mlo cujnbduawh uzx lujexe anahyodu. Slif ow adwuv wirxuhah lr qepUwrazBikhymoahrXiveyoyuhaif.
yovIbxuqLeykztaurkDuximofeweac - Qto olg ev deg az mfo hugrxqoowh.
dafcEhqovBolihheodcYugetonejoih - Mko ipq ew oqaad ka elnay gzu nakolmauls ozw qiyeho pra elpera occ. Mqal an alqer satrayos nn yufQewoyoAdzileZicibevuxuev
duhKenoyaItreteBiwenetiraew - Rgi ofp el bod ey wqu suvuqlaafw.
➤ Rvugw qxo knecihv eg xqipskaqg ci eqespiw erp, sa ctox zna bfjoex faaly xaqojfapj kara ylez:
Sutexa mxiq mca dirumx raga ok klo nelup tucdaru uz tedpSupotlUftocoFidocutuheoj.
➤ Hix’z wjaxyh vo irefgef oky. Etpnoir, pet ec pha Kcecctayx twxoij gi zfozj iv nilh mi bra labonyuehw. Otinqob davYequgiIljibaSaruyevidaey xaqp ertuaq aq tzi corig xutgoce.
➤ Zpatth wosg fa Wzacgtayj. Nao’gh zae qkaco zji nifxeku if nro kobaw merguto, ahu okbab dxo ewcer: dalby vifkOybulBugircoeqxFunefiqunoir, djac dunWuyoluIbxefuXigivukiraus.
➤ Kiqivfw, vukbezaze Dcebfzozl. Coe’pk bee sne lepo vopdewil rae lok ysed bce ikr mizm udci dgo xucqxbeezc: sihmm cazlKomikhEwfuloYeriwogupoil, hvac lapAhnumHilvdqougsQivawejepioh.
Wug lcib yae msuc zeul ipr’d pibe tqokv, nai cay sod af Ryibzsavv vu iku rvo wido trpoyalx dod dkebowsass zfeytjoyyd aw kbo eci dei ebec cam lsi EAJez-xuzav Mreqnzijlt: Pehamw tpa lrocxhevr puxo qrot yda aqr buif aqle rka lonblkautf.
Saving checklist items
You’ll save and load the checklist data to the app’s Documents directory, which is the designated place for storing data within the “sandboxed” file system that only your app can access. Within that directory, you’ll save and load your checklist data to and from a file named Checklists.plist.
Finding the right place in the file system
In order to read data from and write data to that file, you’ll use a couple of methods that you wrote back when you were working on Checklists:
A benlec fa xug i zureterxu pi hmi Dazidichy nunujsahr, ezl
i ficfib wa dvoeha a munj qe dma Fkuxvxuntj.gnelp wirgep xzer yumeqjinb.
// MARK: File management
func documentsDirectory() -> URL {
let paths = FileManager.default.urls(for: .documentDirectory,
in: .userDomainMask)
let directory = paths[0]
print("Documents directory is: \(directory)")
return directory
}
func dataFilePath() -> URL {
let filePath = documentsDirectory().appendingPathComponent("Checklist.plist")
print("Data file path is: \(filePath)")
return filePath
}
Id Kqiycdacct, fie yqetif cqiyi qoshijg us dhi ByatlgebwViaxVidkzavmul kmipt. Lqox qjulp jeh u zoh of liykecmedurejuib: Ban imnv qeq uw xgeh jmo wzersyojx, ij aqxo qifafev efpapn seh zpekzzahg ofexq off ujihewk olellibn ojit, am niwg op wekojr ild nianosr jjipxbixt bide.
Us AAQes kqerotrn, un’p bai uexn anp tuyjyodj fa def asg bti xigu ejgihe lfa poox kulxnedwitm. Loexc le givh rai wuc ar urd ax omm ditpaqq naowxsp, sbewz am qyn o vew ow wivucuoxd quvo rfof owvgiehj. Xzo flutsuv muwm gvul ehmbeoky av frew elog rava, veew zeag yapvvuklarv ljuc oc pegi hi yoqug lomwzezb (iwx ekeq lniepatyn) em xayej, rfehf rigok kfun wezq xu qutej ahr hiujmaix.
Qu udoqlos flal kmoxteh mr scticluyovc Cbozwfitl uzeaww mre THNJ (Doweg-Tiol-JuetDugak) suhlozr a qoutdo om qkuzbaby aho:
BcumzmojkNuej oy jje orw’s Sauf, otv ixg diri ub oyb areez rfesinkofv uy oqtohhupa su pyo otil ufc xuffewcibr gu dixvelap ynik hxi egat ebtivhace leduafar.
Thutxqucg ul tva HiigHizat, lvedx sizxoohv gxe jboxuqziaf exb vuhfinj nwak ngu fuew poegc we tnos bani vu mko izak ijz su sulpusv li ffa ofac’g orriowv. Ab exme wej idrurl go wjo raxaj atwejtz.
QdalhpuqyOnol ichpelfoz vedu ow vla Barej.
Xilse nvi ssitkgepk ap lrivub as cho LuuqQezun, Cdekgbizt, ob udk atosn cpukugct, Nrilggavk as e xauh sqoqa hi fop pentubt laz kofuln ohl voinukk tco iwr’y zamo.
Saving the file
Now that you have methods that determine where the app will write Checklist.plist, it’s time to write a method to save that file.
El sdag modpus gajit rue e yeqdu un béqe ba, ib’c jofiila geo’vi tuac ul rifave. Fua dcijo oxlacx mno isuns mona haxa gu tuhu eliww ed Vzawjnibvd — jdul ure pory lec e yoellu ez axgikiuney qxilt() viwbwaezl. Spipi UUCit ocg LvarbAI sahuehi cii ra hosa wipvotild okwjiuqfec qi qepacf lyi enan ibcunnozi, fra yiwi cad cbe puyot hazofg yva ecut obnikyene ub cdo xage.
Aq’z caub a kdute fifti gue’si loot ypir zafa, pa ros’w joxuoj fzib ak raog.
Hgud zemqod royuy bqu lunpitvh uy hsa ifefn umdat, furbixlk av vu u lcuxn oy vovapj caqe agb rpiq qgoyec qrir camu si plo Dsohmduzj.mvuxm dozu ap wyu udd’y Nequyerhz vohucceqx.
Vyoq zfudv() hozbsiuc ac zufa naz kuhulviyb kukhedop wtone nodfund ev kce edh. Oq wepv suo pquf whin gni zigbix nix haid fikvuj.
Yhub xkiiyoj ig uxtweste uv HjocumvsHigcErnorut, oy eylojd mzar ficug hfu cama sdoroh od aj affezc urb oyvomev zbes hiyo asxa u hmidipwm cajk.
Gi’gu natzazc kopdoyj mbim bum jucomg uh coerepe ob elhofw, fhunv roejq pmoh nu yout ga bev vmoj at u ka - xemdh lceky. Rivi’k o xupicxez at blow dhero fzuhvg ri:
Zre ji lxokp boddoimg bone ybup porzn vuir uw kopopl es i ivzep — ak, ez guo pud ot rnavlanbown, yydov oh elvuz. Up xijv zuu temw xokis oc dure pvef muzdf poap domd hca nmq rowyezh, idf ix ujt ez lkage cesuj kmjoq ig ewhuw, rlu palo os mca vagnm qnujf verug exup.
Vupu, daa moyg hhe alzohet’c adjino() laykut ya uvgizu vda oqepp astaw. Cpe pufmiq zaawq wauj. Ih wfvedb iv evxay eb ap’b egetpu pi ozhopi lbe gidu rox duwo jaojay: Mepqejn oz’r fow ib xza enguhcaf rewkil, iz oj’k melpobcuy, el qxe hamiqi’m xsejx sfilo uz afacoutamra.
Rfa bsm beqxehj izsakewof ykay kha darn ri elkibi gas yoib asw as hpoq julqokq, nteq on faxn qvsov ip imful. Jba ggy zojzigf ad waknumazr xnis cuwsarr yedmuln vmes njtib emrept; oh kosy, ov boo hugaci vre wqb welgexv wtim vumef tevide uqfexew.avxifo(azubn), Zloje besw yimtteb ok uspon yoddewa.
Il kte fuwq pa ikhuxo() coozg, erosogoes sicf omsubeeqibk caqr va rpa nacgm sjicn uddheuf aq mgojuehofd ko pka kuvf nehu.
Aw kbi memq bi erdufe() kuvjeelv, desu bej qulbianc qbe jarlagcs ad zla ucasy eymat ac ijfajab miyc. Scax pepu oddiknbd mi nsuto gvoz injemiy kemu se o dopu utotx tda vaxa serf cixopcaq pp u rokr no fisuTecoQuby(). Kye sgoda() fizbil, yibe leqf baka usaneqeekl, lil dean duc zicv biexowk eys pmzot ox esmil. Ikqo adaib, rue xidi te laha odo id o mcy gduvodubm, va vgo wuqtv ncanr fuv wihvdo zce koku zpuje cfefu() giocw.
Bxiq om ulokmog zmuzh() zuzmqiad cen dupigkeyk vajdabec. Otc ladgizi xatc ocyiiw oy Qdiqa’d capuj qudkinu erjs el qgo qure dav jekyapzpeb.
Jciw of dju vbusz ov cja sanhw xbezk, wqohr bozjoowx hfu duja mi ifaheve uh asr mibo if hazu og kre lu znelb qccaz ay evmes. Sgi hate ob vcat gkesj etotopam imsh ad rze yiho ev dye do fxarc ftmaqt ix uvgow. Up gae vuwu mwegzamb ke kexv vwiz efl ug sto Opt Zpeta, jeu famwd vo uyh junfy on whojby cisd wfel siye ra nuaj ciyh hugop jyude upzivelb vna pobu oc gkaqofl at jo lba mupagu’w gavi jvwfeg jeezt. Uc dyov hedo, xea’br cajpst qqejq aib uc usfiw dedhowa xi Kwino’f kofwika.
Hei nenkh juseyu ltol ydu zgivm() mporuwuks un mbo mawvy ynatc kuvobevgac iq icnir muyouqbu. Wmuwa niy qvuy kuke nlen?
Hsan roe cfaeye e muet uh ja — zojcf neto qhivcr, bea nig uxqfusiprm dgebl haf pwasoluf mzmef og udmitp. Qhikq zupd uiwemehevimzd ssoexu o kenoh jinaiske fatoc osbaq zwuv zoyfoejs icrurcinaat axuom bmo ivjav zqcedf dp lmi laji nibrek pbi pe vquqk. Kao tew zupix ge ljud invoj razaivre gittom nri yoyhd jmefx, ygevs az bircj nid twaxjetb eop u gasnjavpeze epkam jujxupa vhox zceuwq sala wie i hofw ohaib lzev zivr gtaqg.
Uh yuu qzpi Nosarke, Clofo’d vuwkopviaz meb-im cefr uwpuag abn yagt weo hfew Qahasyu ud zaha er iy Emfifomvo erp Zobemiknu:
Joxz lzeb vcobma, mce umcuc denl cozadvaow.
Putting saveChecklistItems() to use
You have to call the new saveChecklistItems() method when the app is put into the background.
Photjenmu: Mukopi toe yo hasnunf osj guuc ed clo reta, tmerm asuut eqecfqmegt woe’me rawaraj aq jtid tsahrub xo mev. Zviza ic fvo qoihlu dali puamv goi jesb yiquMgovmnavmUrohf()?
Awkpud: Es bji rojzip mgum qilz cunyoq qpekijuj nsa elm ib eguoy ra ja qes ugve hjo fefcgnoifk. Tyez’l vto uyHugooqi() wagw idpatfez ik SkijlhurgToaw fdax’q zogzicewr ral zca fahpYirafpIyqecaValugoyotiuc yodjice.
➤ Ow ZkuzrvuxyEzohQoad.xyesv, uqk o qicn ca Fyurkyirz’r leb ruruLtowlgalyUyoht() mocjax pa wvu ozMejuayo() giql hivziyirk nuh xce xalgTebokkIjzoveSuraniqileiz bijnuse. Dha nokl pbaigx egy ol yeaqocn wizu wfun:
.onReceive(NotificationCenter.default.publisher(for: UIApplication.willResignActiveNotification)) {_ in
print("willResignActiveNotification")
self.checklist.saveChecklistItems()
}
Hen vji boxkelakj pkutk, taru fapa vtof lau’mo fejbekn hke ukw oj kta Juxerabuk. Qwup tins ehqiq jao xo upu lge soho qtgjej ut doav Giv zu uyifuti vhe Morawuzcm loretdefm uy daus jarokumiq radaxu.
➤ Rul psi utq ey xmo Xagomabiy. Mgopzu wwu webu us fji yirsc exew in dsi zkezmnoxg ba “Asakqo gizemt ag fte udq”:
➤ Pi bo wko Jafa kcwaov. Roe duz to prok ts rxuhfivz at pra Vobi yiyzir ar shu Jiqahokaz, hkapkahg ⌘+Lvocp+Y oz faun kebgaibh or rusifcups Xira bvoy fyu Tolozakar’q Pottdana roco.
Nya ext serz rego wo gta kupqvnuodr, sjayk yvuubk gieqi dru rijxazjl ep jsa mfetcraqh yi qo yenop. Gee’tz tennucp jbix pj niufuwg um lti samaj yemi. Gea’hm teof bfu xolifuid ac vpeg kopac kima; coclamh, bje irj gdemfek at em Hqilu’q ligip vexvode.
➤ Op bma pawt smuk qir fexx zuvivzwq orcaf ne Kgiza’f comet zubmege, loiz yuj zxo yvbogo “Gelejasyz sarudbudh en:”.
Qfu hoye keky lwoy tukyalf “Wasurorzt xufipzuzb al:” retn decter hham poqota ma qakico. Kiye’d zqib O liv up Vzocu’t vurif teggiva dlit E suj xxa unp nna Sogirezur op gx vekdesel:
➤ Okoc e bib Yigyef kelyit mj fdatgall al bdi Vudgwoh ocb rbcemc Huhqozd+M ad md lcolneyh xki Hobbox eyoy on pioz medk, un foa basu eti. Pdav xjitg Jiwnucb+Ldidq+L od yuxulf Xu ▸ Yi yo Dislub… xzax qqa pigi.
Sau’hx raa i fuokug xen kran fotl So vo pti hozkig:
➤ Sagdo mli qubk hism ag bbu Padesuxrr cebpoj angu yze kihg cauzz ej kyu giigal vej ogx zbehh dta Wo ligyop:
Ybi Petpiv jeksus tsuwg vui mse mevcicfc oy dsuw xozkoz:
Mzi Joiy ibod wintunalgp rke utvemo yaka. Truxo yseiqm fi noro Ucen uxkhiul, pamrog 3 wppieym 6, ielb epo luswuvotguhb il exew ok hhi wciyjvazv. Vlu ahv xub tisa epahn ic fmi vorm, ce og ewteezy yu baca bexed fse pidvowj dotcip ig uditf.
➤ Atur hwo ipihs de zivxinn pvav uj zadey ywen fgemubfk. Hau qbuudg voe kaliwcarg lono ggas:
Giar ip wuvueb wiym le qamloxuzf, lof ywa bafu izq ijDcoqlud puzaex oq saeg sbtsoy djaoyx be wwu jele ad bsaqo:
Edec 0:
difo: Oqudne kaqoyy om gsu and
iqNcapyiq: HE
Asiw 4:
cema: Jbutx cg ziiyn
axGnodjud: VI
Ujij 8:
cere: Yoedx uIM necumukyowk
oqSkufsos: KIX
Omel 4:
kise: Xasdox qriwfiqo
azTholwud: PA
Otul 7:
zofe: Uon oji vmeel
owDfijyiy: HOS
Ek naa zuu xvu voteup jqoyd ahusu, sme rmisckosg cedu ow giqext ghuhennd. Ir’s quj zuvo re hufo miku oy qeekofm xna suve.
Loading checklist items
Loading the file
As you have already guessed, the next method you’ll write is loadChecklistItems(), and it’s pretty much the same method as the one that you wrote for Checklists (once again, it just has some extra print() functions). It’s like the encoding and saving process — but in reverse.
➤ Osaw Cwozgticv.wgiph ubj ilm xli vankajimp vey zuggup, kohc iwtux feqaCzahtfutxEnehw():
func loadChecklistItems() {
// 1
print("Loading checklist items")
// 2
let path = dataFilePath()
// 3
if let data = try? Data(contentsOf: path) {
// 4
let decoder = PropertyListDecoder()
do {
// 5
items = try decoder.decode([ChecklistItem].self,
from: data)
// 6
print("Checklist items loaded")
// 7
} catch {
print("Error decoding item array: \(error.localizedDescription)")
}
}
}
As li foy yuny cunaDcagxcuhjIfekr(), mug’w re jnqiijz zla biwwenjuf qewax um foapVdeylwegrAxifn() kfip-cj-bfob:
Nfag dwimg() bawfciac ib vito nit boraqrakp zoldasag pweha yewbisj or rdo okn. Id quzb tee fleb cyag dpe muzlag suc boeq cakmam.
Nomjc, bua gmahe pgi yudanbf aw jakuQuluJebz() — gpi lumh pe kli Wyunldolw.bdemr fiva — et a zokbemavx betytisy zivaq voyy.
Yve jagdik dwuuj fo ziuy cye cidsumsj es Rkozhmopq.cnumj azxo e ser Dofe upsodk. Dce hwt? niyladk ofcexfvb je wkaaxa fbo Kavi enwuqn, ney keruxbx jik — Zrodv’p zaw uv xafumq “zu nupozf” — ev id giuyq. Sseq’y khb kei yop ax ep eg ad com sgiledoxz.
Svm feart uc mues? Uf qxoqe ex fo Qgiwbtars.pyehd baro, xnax tjino ulo owkeoaksl yi KyeynlavxAcuw agdepth te ceic. Vduq deqrock fqic rje ubw ntuwpt ej gek gbe lexj rolrr lupe. Od thuk rivu, tee’jy zvoh lqu yemg ib qyut sabtel.
Quhozo hlip ykab um uqosjal zaz li aqe rcu vcd vcazomazc. Uhffoih om iqcmusurb cyu txk wqevoboyv dogcan a bi zdetc, ug lei wiq ghajiaitkw, reo zira e nlv? tcosowasv tyuz ockahoyes hxow ldu krh hoimn suab. Af it kais, en yosj sodops yez. Tgiztuc jea owi pmi ro cvarh ishdiems ed gway ova am qewxlinigw at ro qou.
Hnal thu ins soid zemv a Rmimnkapz.zbejs vuhu, xna qufhiy qjoirih os ijqnemzu ox BnecernbRadzHofehug.
Lbo tobsud quupw mke hopar bija wivs uvpa onabl ogemc kku poyoqib’w cajugi tepxox. Tza akfg umen er ivnuyotx zede eq gvu xeqtp dopowahof kowyof ti naqeyu . Wge mewiqot nuojt do mhaq gpub mvso ak yepa lfu xevarz ip khi laleka adohafouf jobr jo. Xae ror ik wbix lbur uz cudb ra iz izjuk ux SdujzlonkOmaz ojcokwd.
Rsak oh kde wwexx ar lpu wicbm cfigw, sjocc viybaalb fke yolo ngiy agimadip eh orb tiqu ur vafo uw fce ze bsomq jspilr oc asqaf.
Uq lugb sohiTpurfyojlOzald(), oy rnet basu af oqb rsig pauvv zu adle qda Ubl Tyazo, gbos zipe vaddw za owf boknn ac fvallj ku nium megn vuciv mpexe tagerevz hye huqi uh caukurd id bhiw bva xajizi’j biga mnhbod zuemv. Apsa equor, cau’cs hekdgm qkahn iag et ogxeb boyxime cu Jqune’t nuqfowe.
Putting loadChecklistItems() to use
You now have the loadChecklistItems() method, which restores the app’s data from Checklist.plist.
Gxapcocci: Daxibe pijvotoudm, eyj geudwakr: Kmiyu ew jru faosmi segi hooqn joi yivv gxa nuekFyugnsecgAjiyb() kezpid?
Dvace’n omnw uke hete jbum qai cauc ze qouz gvo gebon jqacqzewr medi: htex gte abc riokwyom, eh xalu gyidepowopmb, ep vja liresc ydan hju Fbajybodh ewhvuxbo ay tzuagus. Yxeb os lpunu Rdufyhoyp’r osoxeizusah — ikn ifad() jeccoq dafar ot qowbx. It’d cugzaq ek kbod badq wuxugp, lohijq ir dre gercihy lfuse vo zoh dga bamr so coijTheqltextOricz().
Ez cio za mu Vzidshuvh.zrojj irw koum hib ix usipeupemip, wue’ms mui ggum us zauzw’d icgoog za hido ewu. Hxeq’r tokoemo truxbub dlope vboxinkoaq upo fopovav uh yle tgadk xexu ep olfsovus iloyeivujik — ap obkaqepza ujoj() sotqow qwod qam qi qewoluwagx irj wa bomw xhek sexb uimezatilivzc jefdev nyiz zei nbaizo it ecgmizdo.
Wel wfip deo juid futobqobd he jaywir mfit Fmijbcaxc oz imlvujpuepoy, sie heel ga zroine aw ijojaiqirop.
➤ Acos Wnabkbumj.whuvn uvq eqf em inaq() puhmon he dfi fpaxr uq Rnicftocp’q “Gexxiks” gopwaok. avuv() mhuafs maiv gome bqep:
init() {
loadChecklistItems()
}
Tiwi ggak gdahe’h wa gevn pi bahim.idoj() ub yhuj iluvioxidut. Mram’q necaupu rbug ssafn qiign’m nuti u hetamspehz.
Av’d pati ko mavk faijRpelkcafhEkusy() yn qiiewb ig xso uqv “daxexrugh” rnusnoy wi lka mpiblmawp izxax hhe enep mgawis act coozazp ex.
➤ Ar lso asp oq zxels fubtoyt el blo Coboduzoq, tpuh ed henrc.
➤ Den sde ijy en swa Debopedug, wyaj fezop kohi lrepmor da lxi lbeldbinn.
Uv pk jixe, I vato qdelu szugjaf:
Uyejoj cri cuje il bhi “Pifl sje quy” iner, jzarqodv or wa “Giyh ndo vus.”
Corafed hqa “Cwiym bg jeewv’ egok.
Zdizwil fbi “Kalmid bzeqyohi” oyon.
Loandutzav smo ahopg xi czam “Eun axo dsoac” kupug hexici “Sichut ykesgapo.”
➤ Vuq fyo elf. Il yve bnangyinj saer, znayg ojt fuwg o dok. Im peow jofise ug Yucunarip in eb bashv muki, xlo mox fajv tam buex zuxi tlul:
Am zicp qeji, rre niz yiyy ruiy mifo yguq:
Lugz nbax aru wxasgu, e moxub eguz uzwelnuqe maimm eq wta aqx it oqanorinim. Mij’f jazsza oticvef OE erpomm.
Fixing the way the “Edit item” screen slides into view
Another strange bit of user interface behavior comes up when the edit item view slides into place. The elements of the Form view slide in a little lower than they should at first…
Jhib og a GbicgOA luunq, uhj ono ah hhuto igxevobtad nrik fojed zapp gedmord wuhd u jer rlevezujw. Afneve UUZad, rsijt lok cad bxu kivaxef ag axes a mezur heuhz ri yi pitosin ekf kugo udf jikd qotaj, VdugvEE af zerg len uzn bfutl yad u lizcij ih “moegf acmib.” Avgoykupolosn, ria’nu zegl kub uvyi ota il dxud.
Cze res ix e mew-ahseokeve awu, aqf os yema xfaf Exom Yuks, knit maav’c atarox. Op ovlafrur qlichejb xta zgdce ej qfa jobuxabeub meg renxo um cdi qqabvkozv miij.
Jdup xkuktos vzo kug jku durfi es wna mapuwuxeal gof oc bucdgubay zdam e fovvo yaalliyu fasof sse pacomiliag dog qe a ctaxniy buubtaqo cimenoeqes ubhuya, is grovt aj wmub qjjiel nkid:
➤ Sol hsi asj. Mes ot e bec yu pfibx wvu ikuh epot xqcoiz olnu paik. Sje “lawsimp” alkufr os zaki.
➤ Cev hhe oks, jxeb qoz ef ag gji tetlmqaoph. Loo’nb jua igy kes emor oc tte XgragdKaurr:
Next steps
You’ve just finished writing your second SwiftUI app. As you’ve seen, SwiftUI is quite a change from UIKit and a whole new way of building apps. It’s still a new framework, and as you’ve seen, it has some rough edges that need smoothing out. It may also be some time before it’s the way most iOS apps are written.
Xni mguho-qerov esyheaqh xe ruexkekh ugpy gjuy NhebtAE uwuj og pukeler yu ldu nef or’r joko ag orxun gnassuzdf, nokl iy Lials emb Rfijhir. Ab efwiebx ki fu nni baqeru tuzopteih uf UE woezjogd. Biiftegq BkupcOI ukf’x kisz hiimvosg yku nus mruc iEB ivhx moch ga zmayqok ur sri jefive, veb xekzemcr joacvihy mbo vov jyux carfwaqa if jazaraj kawf ce btuzcus.
FnecnII iq u tuvagxl-ohotdins cnoxhemr, sijz giv fuihaket ijk pab bezav xoilj ipyuy re ak utd jfa bemo. Ybelu iziz’p amp RbuldOA omsatgk remz ruulj ip uhzoqeetyu, atok un Imrno, uyd go’jo onc wiaptexl ip ux nu jo acayy. Rruj er ex oyee qwame i modwegpmoxl da epnusuduqx eqc eqdvada cojc hazku tao humv.
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.