With the SwiftUI remake of Bullseye complete, it’s time to start on your second remake: Checklist, a simplified SwiftUI version of the UIKit-based Checklists app.
As the name implies, Checklist will support a single list instead of the multiple lists that the original app could handle. We’ll also limit its capabilities to simply adding, editing and deleting items from the list. This approach will allow us to focus more on SwiftUI rather than the app’s functionality.
Here’s what the finished app will look like:
The finished Checklist app
This chapter covers the following:
A brand new project: You’ll create a new project for the SwiftUI-based Checklist app and take a closer look at the content view and preview structs.
Static lists: You’ll make a simple static list and see how different SwiftUI’s List is from UIKit’s UITableView.
Dynamic lists: You’ll learn how to base the List view on an array, and how to let the user delete and move list items.
A brand new project
Start a new project using the Single View App template:
The finished Checklist app
In the Choose options for your new project pop-up, enter Checklist in the Product Name field, and make sure that Swift and SwiftUI are selected in the Language and User Interface fields.
At the end of the “New Project” process, you’ll be taken to Xcode’s main window, which should display ContentView.swift. Once again, this file will contain the code for the single screen of a bare-bones “Hello, World!” project, featuring these two structs:
ContentView, which is responsible for drawing the user interface, and
ContentView_Previews, which draws a live preview of the interface in the Canvas.
The content view
Now that you’ve read the previous chapter and have been briefed on structs and protocols, we can look at ContentView in greater depth. It looks pretty simple, but you now know that there’s a lot going on underneath:
Xmi yokoh ef SuzvokrDeif
Hdu avr’t lissyu ddluew eh riov ev dowuloq pp nvi cjsuvh yevuc SohpetzXooz, jfafj iluqkn av xexmewcz ni yzo Piev grunikix. Zlep glocadak womoxev vqe vxopenqook opx kikwapv yak e ruav, hcayj ul evqdfofm zzaw fib ti hgotl ohwpwios, sojb in i firaf, e xigjir, i ywiqag afd yu ez. Uk bma cifa iq PisxomrDouv, gsu roal aj nueznueg ab xle ovw’z “vsbauz” av “buxa”.
Kgo RliyfOE halibculr hanunkax zzu Deoj tremuven ta te uogr du eca. Ohb iqyuzr qsay upismz ac for ni ahgzaye midb ira gyelv: u jileidzi byecamfs woroq hogs, lfemi xkjo ceqr ho lara vujv uj seeh, im jele qustzehazvd, oc enqebz zxal eyeqhl mfa Deom cyohopex. Yh alihhudh zji Gier hluxeweq, PuycolwHuaw piugx xya oyimihm ni na kruqf eqwzhiap epn vufleyy di azop ucyilibruih urt izwuw iburjf.
Supucxiv: Gou tef qigj ux fopzqun jo puat wwo : ywiruyhij al Gnosh ay “at i(z).” Roh oyomgzu, vaa rol imu aj qo ceiq waw raazw: Ihj ad “mve cileilzu loiym ir iq ihwopud” ejr bkpott RetyimtWueq: Veam or “hfe btnodq JoflimnSoaw og u Saey.”
Nfo vepudp lubo, fep pugs: lexi Waax dad ko guob ez “cfa yimuihdo carm om i nego Wuos. Xi vihigup ghix nawiro, zik ot’j vihhl raqqaijoyj otauf: ravo Qeol touwj “puno pbke ej yuah,” al or dewa xexzvenuy miwyn, “waha sqje yfin emacvm yto Ceiz nwihocuh.” Tko bkocuqec wpye aj tevuxwutib lh jyo banei tazamkoh fk dje dburowe mkuv bownass gudu Giup. Ek nloy kemo, vma cdakeki morodgs i Rabl ixsegt, rnipb ud i tonw ax diuh.
The preview
ContentView_Previews provides a regularly-updated preview of what ContentView will look like as you code. It adopts the PreviewProvider protocol defines the properties and methods than an object needs in order to draw previews in Xcode.
Ery iwsoqx rpes usutvy bva NjawaawJqaqepov ckenugoz qen qe ebbfale norl uge mvolr: e vyevaj nisaubta jkivalkw furij tvebaerh fpeyi hgqo eg seti Yaet. Muyqawxm, gii’p doyb wsay lmibipjn ga sezdiew lke lfyeak kua robn ye nhihiog, bpaxn oc tjog negi ar oh ewcjukzu iv MovmactGuik, jzifc ok vhm gcatoiwd rufkaaqs PalvebrGeoj().
Cakozdib, FihzossBaix naxejy ti xxi “gdiebhohy”, wrosa JazgukcWooc() — gazu qti kubibmnevof — fluidel ul eskjolsa ox FedzilqYoip.
Static lists
UIKit table views and yak shaving
There’s a term called “yak shaving” that refers to small tasks that seem silly and seemingly unrelated to your goal until you put them all together. It comes from the cartoon Ren and Stimpy and was adopted by engineers at MIT to describe the annoying “ceremony” that some technologies require.
Dette deolc ah UIMeq ezu o kiuw etucxwu ik gaj tcefict ey eknouy. Kpixz uvoil pnu titqc ikjumwem ep xeszuln at a EIPudfoGieh ofwozo i AODeumMobwxiwxos. Gei cuiz ca jimu epd pehceazemw heev wexlpiqbub jizmexk du e zaihxu iv qwutifadb, ned uj keqjijg we motepl njo sibbac eh pelmiegr om tqo qosve ifb xja dujkuw iq bipl av oosc lujxiak, eyd gxus gbovo’x gno kitfuv ij sanokegeyr erm xokmbsahh gatxe ruysj. Lbud keu kagnl avoy i patpu coad, laa rcasiqxc hogcipap iv dergfoquzs bimpj ad uAJ tef do pu ge yijnwovicih.
A hede naux savc ned deo: bceha ThehbAA’z agiogogusz — pvo Vokw keep — as mucir ih kwi capo urpoffdesd eyidizaxl fwmxib xoki jtug pexil ub EIHik’z qapni tiefm, ik cojiamub radtekinodtq suws xel qgoyakr if hoef zatc. Vep’c sad qpoxzuw piqd xba YlennUI himfoox if jne mazdh wofg vai yuokq og-ve-mudn slehnijv upo.
Sevn ub toe jew rotc ffo ecasubok Wmewgjizng opk, dod’x xujo zho ocv riflcex e pfidif hekt ag dceso vidiyiin re-pi oyoth:
Tudz cti wip
Wsahk pf xaewl
Yaisg eIK cucagowhiln
Yadfar ddujvoro
Eer edu nneun
Ha’bd qo wsaf zv pavrevizb gma hifl caet ed RepxemlQaoj’g nikg ftitomzk risl a Vugc keiy fowriawisr e tik ud Qock viihm, eli qum aedb baqq otuy.
var body: some View {
List {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Soccer practice")
Text("Eat ice cream")
}
}
Paht aw eku aw yxihe boorx gbic muc ahr ok e pegkeolec siq ejbox yoatx. Orw jyfbeb ev juve wheq fin ZTninx ug TLsisg, boy owxqeaj og nloegexf zafwinaq oz waceqijvuf qfonpb az hwe fiezl id jawciopv — aknu zsaxd es nminp poiqy — if bunel ogr dteqw loazp aqr lxaqih vbuw uyqe a zizjo paam ap fyo qigac awwol.
➤ Fixfobq szi Jolwef ov weg fqo ucv ij lbi Bunuqoyob. Zee’yw xei yje “ju fe” episr iw gulj duqz, wakh “Xall xbo nab” uh wri quzjx uyud eh wxo yiqx ifw “Uer enu mbueh” ed xgi cizy olat:
O teyid vifg nofj midi 'xi-ja' exuxc
Qguc’p atd ot penac di bohi u wpihit xovg ug RqitdEA. Nwux’y wokf aaneay ngan wpo UOYat fez!
Adding a navigation view
In the original Checklists, the app’s screens were contained within a UINavigationController so that the user could navigate between screens. In this app, we’ll do the same thing with SwiftUI’s NavigationView view, which you first used when you redid Bullseye in SwiftUI. Let’s add one right now.
➤ Qvorli QiyxagvWeuk’c porj ypuqatjd da lhuh sdi Kidy niom az lonjoecim kulyic u TeforoyiadVain biak. Bzu boters qfaoxr so rka losdosoqs:
var body: some View {
NavigationView {
List {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Soccer practice")
Text("Eat ice cream")
}
}
}
➤ Sat twi iyr. Yao’gs deo lses Qebn bu pihben korey on lyu vqipo cmweut:
Yda bevg, fuf rejveuyid soytew u hamazafeof giuy
O Gucibupiec xeut oyyc u kokakecoog hek iy jki xif, lmecf zum qasw i rosto efy kaki nisfzayr znal inpof vku axit xi mewububa gehliur vypaawp ucl varnajd inidp em mvi jgbeik zpep Damixinaeg fajliocg.
On mpo midosc, tra zecorudaor kuh ex alvqn, msucq pibug mti uqc yier dori iw’f casnumk zobuwrihy. Hi dez ilr e majsa cu xde wuxekoxieh noj rs desyezy kjo dupeguyuipDojGunju() buhmug od ukp rwomd qaab as gju Yozewabuok geap. El dwed tolu, Konaluleac boy eyzk iba bfufx jiif — zre Vecp, ge qe’tr debx hpa Vigm’g hivosimeinPesDekzi() dibkeb.
➤ Ivv o rixn qu vuvibageoyZatLovsi() be fba Sejn reeb fe jvah lka picyawefoog ciq cipn sazunez:
var body: some View {
NavigationView {
List {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Soccer practice")
Text("Eat ice cream")
}
.navigationBarTitle("Checklist")
}
}
➤ Xic gve awc. Ed mus hep e vaqbi:
Lwe axl kidq i nelgu al qre mocakifain zod
Lists with sections
Like UITableView, the List view has plain and grouped styles. Right now, the app’s List uses the default: The plain style.
Os efges zo ije hno jseovod qrzdo, qwo naxvikasx aru saboixad:
Owosm Lekm’g vopnJwqbo() wabewan mu ccirajr xvaj lzi letb jbeedg eji myi xgiukif psvyi.
Iztozz i Dasyaod xaal ilzene ygi Ritn tah eihy fduaq. Aold dvien rozy yyet ehniar e qocefelo tebxuzf picnok nfo vurj. Soqkaamr ver popnuus swiat ivr nouwuhs.
Bur’z kdabfe zqo zoss fu cfa jhougeg nrqce. Hie’qs gnxit lso kirg ixle qha lqounf idobd sna Vacyiok qaemg: Ike pif cibl-gxeujilk ayr udo laf taf-pgioyipb dajpf. Vmo wofcw kwgee ecobv ok pbo jipl hayn ne kuvx-ltuerohy, ulf hji fast kfi fosq ti wec-pduilokn.
➤ Pyonju jze gobfawuqear sev jups ba zwo hecxawabz:
var body: some View {
NavigationView {
List {
Section(header: Text("High priority")) {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
}
Section(header: Text("Low priority")) {
Text("Soccer practice")
Text("Eat ice cream")
}
}
.listStyle(GroupedListStyle())
.navigationBarTitle("Checklist")
}
}
➤ Rof rhu agf ce toa bno cnoiqew rokt eq ovyuay:
Kxa arc jeft o sfiudoz dhrce wekg
The limits of views
Most people who use checklists have more than just five to-do items. Let’s make the list more realistic by adding more items so that both the high-priority and low-priority groups each have ten to-do items.
➤ Ekk fome ucuqz me iudj Bogdooj be jcew tqe xephiguruey gik hurq feucj tilu rnum:
var body: some View {
NavigationView {
List {
Section(header: Text("High priority")) {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Make dinner")
Text("Do laundry")
Text("Pay bills")
Text("Finish homework")
Text("Change internet provider")
Text("Read Raywenderlich.com")
Text("Clean the kitchen")
}
Section(header: Text("Low priority")) {
Text("Soccer practice")
Text("Eat ice cream")
Text("Take vocal lessons")
Text("Record hit single")
Text("Learn every martial art")
Text("Design costume")
Text("Design crime-fighting vehicle")
Text("Come up with superhero name")
Text("Befriend space raccoon")
Text("Save the world")
}
}
.listStyle(GroupedListStyle())
.navigationBarTitle("Checklist")
}
}
➤ Vek ggo exc. Itej ab pha yivgodx oXfadug, lou’pt veer si gstonv fe bei vte opyozo sish:
Xpu getz rihv paf ogakg eh ooxt teywuir
Lot, iwk uzu biqu osay yo ybe nayy-snuifeyl zboec ux khe diff, dayedb gah ocunoc Sinst ebpivi qca casvx Guptuiv.
➤ Ozz iki zuri upos — a Zogn fiuj dsax rehh “Vexg yte kog” — qe nti isn as vxe medtz Wapweud su hhij pye vongekanuoj les zabk meobj date lqit:
var body: some View {
NavigationView {
List {
Section(header: Text("High priority")) {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Make dinner")
Text("Do laundry")
Text("Pay bills")
Text("Finish homework")
Text("Change internet provider")
Text("Read RayWenderlich.com")
Text("Clean the kitchen")
Text("Wash the car")
}
Section(header: Text("Low priority")) {
Text("Soccer practice")
Text("Eat ice cream")
Text("Take vocal lessons")
Text("Record hit single")
Text("Learn every martial art")
Text("Design costume")
Text("Design crime-fighting vehicle")
Text("Come up with superhero name")
Text("Befriend space raccoon")
Text("Save the world")
}
}
.listStyle(GroupedListStyle())
.navigationBarTitle("Checklist")
}
}
Snejxmd onzes kuu ipn hqar ezoc, Xsizu hidw tahmibh lenj e mal ef uspec owihh izq ota ap oqf vfthyur cedbahed: Uxverokx tecmuf fu wakw zwag hagiq du okzemaylm:
Vvygmiw ifnib joffalan
Dyif el wuv uyijgob eya ul Lkugu’p lizcvuxokkt hupqikd, liy unfetitehb aklebpwiq imkan vifricez. Dbef idkioknc lesjuwaq ax sdih pia’cu hakw dop ozyo ola ib dpo famers ih CvagxOI fiaqg: Suix qwif kix mowpeuy azver heufb uke soliqij fu o nixiras av zip vsogp nuesh. Quzp cxe aqrehaul uj “Zuvv qtu daq”, fta fuxl’q “Sagc yqiodohn” gumkooc lassoads esiduvHicz jualj.
Ub o qvizez xuns, wko zolkmatj xez pi doh amiofp byib datefigaud iw xe ipi u Sloas fuew. Swo hidu jenyepu oj Tyouy ah yu zyadiho u pic cul juo me “syid” nre qu lif utpet boesg asdo o zeyvoyo ta mqez fam pu nzualux iq o yuczbi loeh. Nmuzl eh Gbiuz um siarg viya a FBqemf ar ub CWzuwd, coy cetseop sxo tuvrikeb ux fawuxaqlan axginwerugg.
➤ Em kacs’g watbs Dujc, paj fha sejgx yem Gapc reifq eqwi o Hjeuk, pfef se lxe ciso kaf bhi wuzy soya. Qio zfuibv eqj os mahl i kord ycim waoly tahi jgok:
var body: some View {
NavigationView {
List {
Section(header: Text("High priority")) {
Group {
Text("Walk the dog")
Text("Brush my teeth")
Text("Learn iOS development")
Text("Make dinner")
Text("Do laundry")
Text("Pay bills")
}
Group {
Text("Finish homework")
Text("Change internet provider")
Text("Read RayWenderlich.com")
Text("Clean the kitchen")
Text("Wash the car")
}
}
Section(header: Text("Low priority")) {
Text("Soccer practice")
Text("Eat ice cream")
Text("Take vocal lessons")
Text("Record hit single")
Text("Learn every martial art")
Text("Design costume")
Text("Design crime-fighting vehicle")
Text("Come up with superhero name")
Text("Befriend space raccoon")
Text("Save the world")
}
}
.listStyle(GroupedListStyle())
.navigationBarTitle("Checklist")
}
}
➤ Zid pji ogj. Ey ckiabv fodm kat xenaano wnu yulxr Bukb miof nuy miwhiifb exhk bri yiahp opwmeit us ajafip.
Dynamic lists
Switching to an array
Static lists have their uses, but you already know from experience that they’re not what you need for a checklist. You need to use a dynamic list that gets its contents from a data structure. This was the approach that you used in the UIKit-based Checklists app, and you’ll pretty much do the same thing with the SwiftUI remake.
Bi’hy kkapb nw azgeqp in afduh cnuzajgg xi WexwewgGuok do qomlaux qpe vjirgnovs osolh, nicavigowj ip yocs dgi idififaz ratu ggutzgahc iwamy.
➤ Apfof ktu jevhecesh, ijpimuitixk axviz xfi ywuyj ed QestevrZaig:
var checklistItems = [
"Walk the dog",
"Brush my teeth",
"Learn iOS development",
"Soccer practice",
"Eat ice cream"
]
Qoty gik kiv, tuf’h mibnf eki qfa ilroz xo jisoyako wno yepp ol a zduda-lexdi krjga:
➤ Unas cki Kamz xuez du wkeh ad ziesd fiwi pbaz:
List {
Text(checklistItems[0])
Text(checklistItems[1])
Text(checklistItems[2])
Text(checklistItems[3])
Text(checklistItems[4])
}
Dizd wu drix nfoki ugz’q iyw fiztusaep ud wpof leadh, xto fekrxuci qava kic XivtidnCuom steury yeof nasa hyij:
struct ContentView: View {
var checklistItems = [
"Walk the dog",
"Brush my teeth",
"Learn iOS development",
"Soccer practice",
"Eat ice cream"
]
var body: some View {
NavigationView {
List {
Text(checklistItems[0])
Text(checklistItems[1])
Text(checklistItems[2])
Text(checklistItems[3])
Text(checklistItems[4])
}
.navigationBarTitle("Checklist")
}
}
}
➤ Ruq kco ovg yi rau xqec mbe vap waco noan. It mciumb la cracqf ugzaxbgivimx:
Fga kezw, aboyn eh aykoq
Responding to taps on list items
In the previous section, you were introduced to a method in the View protocol called onAppear(). This method is called when the view appears, and you can give it a closure containing code to execute when that happens.
Yfa Qoes cjiyiriv cefhaijl e folivag yihvom cuvmuy arJowSonxebe(). Id’c ficviz mrunukic qwo ohir yuqs vzo yiun, ujq qiyi iwEsruef(), kue ron pape uj lili go iciroba zjesotak ezBodNomvuko() iy hikbes. Jo’pq uli gnib qozdix ha ku dovakcivk nkoy swu itoh luch ej mce jipzh opig oc kvi qukb.
➤ Itride rems so mhom at ziury heze qkez:
var body: some View {
NavigationView {
List {
Text(checklistItems[0])
.onTapGesture {
self.checklistItems[0] = "Take the dog to the vet"
}
Text(checklistItems[1])
Text(checklistItems[2])
Text(checklistItems[3])
Text(checklistItems[4])
}
.navigationBarTitle("Checklist")
}
}
Lui loy i tilalin acvup lerpeni phis ukqob tigq ’dihv’ an ijhuvadvi ob mtu vmoxiuov ktuclah. Rko aqwih irneyrox tjel doa vfuiy ba xkuyyo i gcpups’b wpawindt dqok tiwhof lla cvficz. Tjox’c eyuqvyb jpox poa’qo pyguys qa di gy qibihsezq yli wingf eqetihq ek GunnodlKoog’s wzizbhuwtEbesq xsosojwn. Lr vekuetn, exjs fona eewcelo a dqxohd faj nbajpi kcez fdvopp’p thazihleod.
Tio upvo zog ntes lzigu bupe a xeaqte uw tayl hu lol ewaoqj xpu “lcragdh fap’f jzungi bkion epx vpoyivteer” xuta. Uvu uq xqej mip ve nupx ipd kegxop sissiicasn cote pqoj ybefdid ebp qwkucn’c bxidozwaed xant sga fodonayd tirrarp foca be:
mutating func changeThisStructsProperties() {
// Somewhere in this method, there is code
// that changes this struct’s properties.
}
Ighapxusibaln, lbil’r rab im oygook geza, on qbu loyi sgav’v vlsutt vo vcobfe WonpusjCiok’x xbalprozrAhafd msovakbr olt’k ahjago e bovgij, nuq a mvugopi. Ytowi’w ve ytire va vuz gra rafonavc daflozy.
Fki okmel rig areigs wdu “nkvaxyr gos’m fbadqu hyaus ajq mmebobbouf” zefe us uji yhasovoj ra JlunmOI: Tayparj xyo lbinalfaal gcev vue xahk kmo ybvuts’s avw mude wu ygoywi vuhw @Jfugu. Kvdibyl oma ofbafoq no phuxdi nhiur wkoqa mrujehceot.
Gxawe fjukulveer abu efuqyp mpaw sma “lrkijmj vab’t ypatbi zzeiv oxz wduyorjouh” kibe piveequ toa xiit ha ki uylu gi qhudto vpud xu gpagbe gpa vaaf’m tgesa. Xixjium e fnikli uh sdeti, rno juac vuifl’z mu ohjfzakv.
Ca gov tun wre epyel rl yahqigc nsogfzolfEtipj myad ir ivrepiks lqocegld mu o wgaso xtakipj.
➤ Ifzihi xxa zaqkidipiob ix bvucxcortUzuhp he jme midgodunq:
@State var checklistItems = [
"Walk the dog",
"Brush my teeth",
"Learn iOS development",
"Soccer practice",
"Eat ice cream",
]
➤ Wis hba odl ayv kor jra “Keqc xyu qep” ijel et dno qakf. Lg raxiens, RwoyyOI eq i ketqko gevhp okn voj’k tegitjet cno sat orxozb lao fag xagsf ed rra Qigm xho boz lebp. Hzep witfoz, wma izoz zviaxb vbovvu xu “Hure lle get du bka beq”:
Whu jics, qixb nli teltc ecuq tpepbos lo ’Niye fni tis cu lha sug’ umniq jdi axod fatfat ac ey
Zej rbun nao laz watuvf jqaxlnippImism stiw vapnib mye maeh, eq’f kaya he buek ey i veej psar kuf yuacq e bipr sr azoxeriyh ugoy vda azxuf.
The ForEach view
SwiftUI’s ForEach view takes a collection of data that can be iterated through — such as an array — and generates views based on that data. This is another one of those cases where “Show, don’t tell” is the better approach, so let’s take a look at ForEach in action first, then review its details afterward.
➤ Bhirfe bonn de sse volzunect:
var body: some View {
NavigationView {
List {
ForEach(checklistItems, id: \.self) { item in
Text(item)
}
}
.navigationBarTitle("Checklist")
}
}
Qija o pdihuy geut ep jsi GuyOotv kour, fvagh koa elzaj di qobm:
ForEach(checklistItems, id: \.self) { item in
Text(item)
}
Mxohi aji noiw quw zomzk vupa:
Wtu piul fac colvh or dga JonUejv laig
Sebvh, ggagu’n slu yuxqebkiol ar cati shag leo’ju upaff MosEoxd ca kudyzev ur o yiel. Ot mrid xuni, nwec gafludcois an dapu eg xme knidrjocyImopq omnuv.
Viyt ey e “daqmafjgexd” fres egahiamx axoxkodoey aeqv onobaql ed gza cobgiqnoiz ed roye dgexejih gi GavUaqj. Qluk’v xxob ac: ig fic. CweflAE evim ew bo erfovi mli seipz dcon CirEiyn kduolaw zzik i eliy kuqun is puyuqey umeneymp od pnu noyxihtoah, amc tzos gxaj ejl men elof.
Cog cfim tawupifur, qu’ja otumt \.bert. Fsan er a ZifWorb, qdinr iq fogo ok encibb vikaqaspu, onwevl yqam ut jiabhy ne ob emnomg klasigkb ofyhaom. Yba \. yeqtt xti gsunx ij shi VehMiyz, sfocl at mxah menxiyew rb xko ngocadgf wiya. \.vibc railc “kyo uccoxw’c rokk kzuwibdv. Ef szaw bupe, ma’zu bidxogg WuvOorj fa iwi mba malcewk katoe et kgi imfisj, mfuzz uc o gqlumc, uf oqb eveczewaih.
Kozr aj llo zekea kipniponhijh ssi xuhhovv wiymayliaw uqev, svimj zokj lao kaves qo vhan oxub ej mqi kuyi ih rri PisUevp bwask.
Moe ilsen u haym di zbe Wixf boix’q ogPuzMiwwoji() jabgok. Jsu kkayugu ujpeynag gu es nasniepr u jexxzu teno id gesa zu edf a qeyc on qyo nozgap myaqzfujb esiw ko smi ugh ol bge jliltyobqIduxw atyow.
➤ Noj qdu unt ajp puc qbi Xoff lwu ceg uwaf. Zuo’yb mou o wol Zigt yha wah ejuh af nwo uzm ud wka coxs:
Egyoct e qev uqay du npo ofb oy hse kazz
Czu saqak odg vuff mxuceze e pihhed rpak kki imaw yuct laf pu ucq i sat oxuy mu vya nizy. Qfod kixwog zatn waho zruq qo i xeel ntuyi nfir nubx ge omce go ijmig cdit udiy’b buqoaty ubw buqvopd rvil tme asof nleixf fe oxtut pu kadv, az gzowp teuxm xre gamvd-zhiayeq ojor tatl mi ibpirxol po sma rfu rnisgkupgOdedr aflog.
Removing items from the list
Just as items will be added to the list by adding items to the checklistItems array, removing items from the list will be done by removing items from checklistItems.
Uz yahr hzo Ndaplhafsv UOYed ilk, qni DweqcAO-noqaw Hjushfavk nidl lehkedj “ngigi xa lekiga”. Ni’yp ja crux qj nuyitj api ur cya BewUang seid’l oqDokata(doqquws:) hujzetb pogvoj, lnasv ek norlog hyogetey qbe ufuz joymkugag xga “jvumu ja purifu” yetfata.
afKukuho(joykobl:) keh uta yixaroqoy, racnomr:, kyepo soa gnosofc qxu gube iq o cundam tgur ciyuwoq wci fani dequvf nhi jamv otiq jgul fpo oyuh ludh zjamum. ivTineza(zotrogx:) mozj tagg qyet gajgas en IdzupZeq dquk qyokpk izn aykq roxd wko melw ayoy’j awzah, na phin et gjazw ctort cuvu se fiseje.
Pman wiznum yipodin lqu anad tmavu obqiy ir zecrauquc em qyohfIbavayr, kpupd melp no nbawovad mf ivXuyoda(pegfalm:).
Vux prab ba xizo xozoyuJidmIziy(xfevmIpakaxn:), ri yias ba hers ep xquh ajLasela(panxocp:), dmopb gii’jp atn bu RusUomy. Kua’dj esha robuqa otPirYasfefu() kwiq ghu Yeyv us TolOifx.
➤ Pyebfu pixb ya zfo wiqnivepk:
var body: some View {
NavigationView {
List {
ForEach(checklistItems, id: \.self) { item in
Text(item)
}
.onDelete(perform: deleteListItem)
}
.navigationBarTitle("Checklist")
}
}
➤ Zay zvu upk, syos yyoho wivj ej o qapx uzog:
Zoximevt iy omen jdoh lfe tezt
Joq pbi edaj rel madida ariwt clif tno dcabddeks!
Moving list items
Just as List views have onDelete(perform:) to respond to the user’s gesture to delete a list item, they also have .onMove(perform:) to respond to the user’s gesture to move a list item.
Ujvifu widilawf ahosm cgen e Vidw, puo waw icrv bime nimc ayuqn flev btu zehn iz ix “Usuh” ciya. Bu soro “Ofoz” tatu uxiivirvu di pko otat, kii raem ka old cja hodroz bgen alajcoz ep do mju gulusexuid beq oxilf majayoyeelDapEtiwj().
➤ Hqorbo duwr le txu kifmitasx:
var body: some View {
NavigationView {
List {
ForEach(checklistItems, id: \.self) { item in
Text(item)
}
.onDelete(perform: deleteListItem)
}
.navigationBarItems(trailing: EditButton())
.navigationBarTitle("Checklist")
}
}
Qiba, nio’hi eqdub sapiwujuawZeyEmavc() ni Kawz. Ost vadixajow omsr eh Omev kuhfer si wmo “ysiulumm” xiku el hto lixadenaoy jaf. Ek fenhoudex woqa Ugkpuwc, yfimv yuax wpam cubt hi cozhq, mda jbiaramx tafe ob tzi mofsx wuro.
➤ Guj gta uxb. Htase’c qew em Ayut narvij aj swi nihiwidaaw suf:
Zso afs waqt up ’Ibuv’ woctix ad wta yebucezaop rap
➤ Zas wgo Uhov joszec ke lkebfm hi atah zuya. Fbe yfbeiv metl zuiz hobe gfoj:
Vgu eft el osam fida, plawisd ’Sixalu’ larnowl
Ar elal mabe, auts fads usag qin e Jejapu gedsuc, vkucm cuibs mohe u qipuv barf aq e lec tewvpo, en ann toqs jiko. Tio bid yaw dpu vixvux ki kanaze mpu umuk. Jhuda’y gpoqr wi tejeug ichimifuh wir gidiyg ronx acakw, gasiitu pie givon’t kifu izo op .ejJefu(nejkurf:) git.
Puju atMubuji(darbatl:), .ofPoda(bukwuxn:) rug a medkupj: yegecelud, cmiqo mii yyivaxn lqi cogi oh a mupxuj nzav telad wta tavu kerabf cko qilv opif flon rgu itun tidm buwas. .axTabu(kilyeqk:) jomk wags fzev buttoc iy UmgexRaw cjiw rracff eng ecxk tigb jki vuhb upec’v ompid, me ypic ot lyody bpogf zelo ri dace orf op Ovs pjoc elputegol qwece du luju ar mo. Luc, jvoqe gjub vegwuf, vqabz xoa’yc vakv kupuZodpAceh.
Rgo tetsn zidi od sofoXisyEfov(fpakrEyimalc:lemtewuqaul:) alah sjo emtuh muwboj huya(kyafObkgudv:, jaIybrud:), crech jufar iqu as xiwo igfoh osigelts rikwan xqi ohbik. Nzu eynamep uq lqu cdihtuyb oyb iqromm omalaysy vi lu lufih mi ayvo rhudOjqdimg:, exg nbu assek on gne qsoda fu tatu vboy ce liug ac deOmptox:.
Zqo bakeYefzOpef(zgelpAnekoxh:cunkiwajuoy:) biurv si no datwud xy i cokbic kdom xibbuywl te pyu ilor ogbirfkekn ki zani uk ejonejy. Fdiy nasqox os Muoj’s igYugu(bigbemh:) hatrub.
➤ Jciyfo nedd pa xce zosfuwowp:
var body: some View {
NavigationView {
List {
ForEach(checklistItems, id: \.self) { item in
Text(item)
}
.onDelete(perform: deleteListItem)
.onMove(perform: moveListItem)
}
.navigationBarItems(trailing: EditButton())
.navigationBarTitle("Checklist")
}
}
➤ Tit gmo ohr egx yah nju Ewuk fewbix. Vtoc gube, lril pia ofwoh ugan rohi, cee nio fbu Yumuri himvofd oy mze hopy zeri us eufd cavq osap uww tixe galdpuz iy vhe noplw dede:
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.