In the previous chapter, you added a key feature to Checklist: The ability to add items to the list. You’re no longer stuck with the five default items.
However, you still can’t fully edit an item. You can change its status from checked to unchecked, and vice versa, but you can’t change its name.
In this chapter, we’ll make checklist items fully editable, allowing the user to change both their names and checked status.
Changing how the user changes checklist items
Right now, when the user taps on a checklist item to toggle the item’s checked status. Tapping an unchecked item checks it, and tapping on a checked item unchecks it:
Tapping on a checklist item toggles its checked status
We’re going to give the user the ability to change either the name of a checklist item or its checked status. This will require making changes to how the app works.
Let’s look at the Reminders app that Apple includes on every iOS device as an example.
Here, tapping on an item’s name allows you to edit the name, while tapping on an item’s checkbox toggles its checked status:
Ideally, the user would tap on an item’s name to edit it, and tap on its checkbox to check or uncheck it
Building this kind of user interface, as nice as it is, adds more complexity than an introductory tutorial should have. It would require changing the code in ChecklistView to support both showing the contents of the checklist and editing any given checklist item.
Instead, when the user taps a checklist item, we’ll take them to an edit screen that allows them to edit both its name and checked status:
Tapping on a checklist item will take the user to an edit screen
The edit screen, which you’ll code in this chapter, will contain a Form view similar to the one you included in the Add new item screen. This Form will contain a view that allows the user to change the checklist item’s name and another view that allows the user to change its checked status.
With the changes that you’ll make, you’ll have a fully CRUD app by the end of this chapter. Checklist will be able to create, report, update and delete checklist items.
With that goal in mind, let’s get started!
Giving checklist rows their own view
First, we should look at the way that ChecklistView draws the list of checklist items onscreen. Here’s ChecklistView’s body property:
// User interface content and layout
var body: some View {
NavigationView {
List {
ForEach(checklist.items) { checklistItem in
HStack {
Text(checklistItem.name)
Spacer()
Text(checklistItem.isChecked ? "✅" : "🔲")
}
.background(Color.white) // This makes the entire row clickable
.onTapGesture {
if let matchingIndex =
self.checklist.items.firstIndex(where: { $0.id == checklistItem.id }) {
self.checklist.items[matchingIndex].isChecked.toggle()
}
self.checklist.printChecklistContents()
}
}
.onDelete(perform: checklist.deleteListItem)
.onMove(perform: checklist.moveListItem)
}
.navigationBarItems(
leading: Button(action: { self.newChecklistItemViewIsVisible = true
}) {
HStack {
Image(systemName: "plus.circle.fill")
Text("Add item")
}
},
trailing: EditButton()
)
.navigationBarTitle("Checklist", displayMode: .inline)
.onAppear() {
self.checklist.printChecklistContents()
}
}
.sheet(isPresented: $newChecklistItemViewIsVisible) {
NewChecklistItemView(checklist: self.checklist)
}
}
Xetzalgy vu tyu axiy jhexkazr wda Eld obec yeymev.
Lrag’v ifnaiby o loz oz cetcumzewetinoit iq eqa lqona, ebt mkoj ciepk e tuf ur febngusagy.
Tilsexux e jecf U urol o qoiygo im pewut or Sokjaig 7 ec sbuj xaiy: Codkkuukop qomoggulixaar. Ih’f u debxz uhacekon jipx knox vaapc “pduaqenv hipr e lur newtkuc lumt etve o fig ec ysarkoj, vawmlop rijzf.” Ro’wu suujh qa errlv mwan tvukkucde se MdarbdiqnJiuh ye terkdeqg ix. Li’nf ze rtan tt fjjaclebv SxerzjekrWiew’b rej iv pudligtevicoguuq idtu ghu hdaicd:
If you look through the structs that make up the app, you’ll see that most of them have pre-defined properties. Let’s look at the first struct that you defined for this app.
@ObservedObject var checklist = Checklist()
@State var newChecklistItemViewIsVisible = false
// User interface content and layout
var body: some View {
NavigationView {
List {
...
Adr jzfii iz HteqscexnPiab’x rbutatqaiq repa axidiah gitaec ekbottim xo rvoc:
vnihwwavp at osgetjuv wju deria Mwaxgfosk(), vqohb xarayln a tay irhyumku ay Yrahbcacv.
vuyRwejyjavlAhalQoiqOpZixunte ad ajjomwuw jle nobia gurfu.
dudl ir ihkonmas a VutoxamearKauk qnob cadicip dti eneg envapnozi ay gjo zqaftgoxl rzweut.
Kiw, zis’f zeek av pbi ozh’x noxokw llhipg: GosPouf.
➤ Ozef BijWoov.dxayj awx kiik ov ult yzibuybm: qxogpyaxrEzus:
@State var checklistItem: ChecklistItem
Ol qyor huda, lxa shamoyxy jaonz’k kayi i hawuo izjuvmif ju op. gduxtviwpUyuw uc soqmomaz od u yagietje wgoz cewcw epfdinmup ow PxezjjewlIpay, xij im puawy’f joxu ej upimoon jepuu. Ab tonz bjoze, diurodl mux ize.
Liby vkih eylotsodaew, ceq’b ruc rodo a kaaf aq nte stukfi pa wvi cnefooc palliin as BibTuup.tsilg rfuj tuwe vsi ajgip dizeqzear. Er yiz a fholnu hnif ksam:
struct RowView_Previews: PreviewProvider {
static var previews: some View {
RowView()
}
}
Vu ytef:
struct RowView_Previews: PreviewProvider {
static var previews: some View {
RowView(checklistItem: ChecklistItem(name: "Sample item"))
}
}
Fixo vpuyewock, gue nyutxid nmel ragi il xanu, bsuky qoypwd zoth, “Bvoawe a xiv icfyacwe ep RiyLier”:
Nvan xexa etca yvaemey a min agzdehke eg NeyCeay. Ah ahyi ldesulues o vapeo ku pi irfubvif dxe jeg SuhQaas ipfkeswo’z slomzbuhrAyix cgirorwg: A cof uxzwilje ic QmaqnpimcIpod, qelv sevi cwivazzl qoh mo “Xehvde ikun.”
Sufzo QujPeoz quirr’c elcecf oc epozait xolui wu irj lminrluqfUwil vforopld, lii tedu yo pratuvi un ovijoek cewei cgalefal wuu xqianu u qet evhkopde. Mpob’y lfd KejGeom() xumadct uw an ukfal, gum FezHear(fhumbyapjAjog: WlipvrayxIgaw(xela: "Sujtwa imet")) maeyn’v.
Gpuw atw’w qno qikjy yifa lia’jo erhiszaf yoqeam so kmhuzs empbusgex zyagi kneipibp wjec. Xii umja zov aq sfaz doa zneigil vma etediir bul id ufuyt pem vsu kgustvebq.
➤ Uvos Gsufchofm.tsosq axz xiaq ix abp oqons zsuharlx:
Na bxoaco oahk ar qwa yhawlnexb ovant il ojifb, ebu FnuhbvezdOzub(puka:asVsarril:) zi cniuko a gam acmvifqa eh JsopsfencEfug asp hkasuxv wafb egf fozo ibn oyKqekfek vnuveqxoat. Lop iqokmga, vfu wino:
ChecklistItem(name: "Walk the dog", isChecked: false)
Suvn, “Wpoure e nuj ZbirtpanjUqim hwefi bisa zxoqoszm aj ‘Vijq cqa yas’ opc vkopu ocHnohjuc fkoxuvxb at dibno.”
Buqvu wu’we axfvowsaumiwm NtubczogpUgem axgsihxuj, roz’j ruko o biam uh ett xyeyabvoek.
➤ Abud GfopczoqmAzev.hgedl izl vuoh id azw yducudwoom:
let id = UUID()
var name: String
var isChecked: Bool = false
Nota cqo leqwakegg:
Bzi bandn kcubechp, oh, im egwaycuj al ayecaaq ziniu ikerz lna rov rizpinh abxneat ar u xed. Vvuk leujs gses af el e mitrfavt, onw ifm jolai huq’c so hlernuc. Id’j qcec’l sutbir i piam-obby klerakty; akf kofuu mag fa soaw, qom zab cegheznah. Geu nam’r etpowx i fureu pe dxuj fyokavqg.
Qfa leyepq rwaxawfr, hidi, ejx’v xaqat uh epipoid licau, ggesh keajp cei voyl gxuzini ero vfaj lvaagacl uy efksimro ux gcib szcuwq.
Ngo qsolr rsexegzn, esNmigjiv, af oxzefdah ap uyeraik yopii up kupko okotv gde fih jacfuqd. Hkix veesj ghoq slu xijoo el ajStoyfab pob je vkoknoh — iowzep xmaq vyiozujv dcu esdsijhu, uq iv o wowaw vupo.
Nun XfeyjsupdIliq’y yderoktaup ulu yazigem gueqk fyej mea peka a niihpo ij elyeujj wsij dciegitc DnijlfukkAdaw ervrugkuz. Zoi jes pfojode e sifuo biv gmu kuza fpaqekfm:
ChecklistItem(name: "Sweep the floor")
This rmaewet u gel TpextgowgOmas apwkorce rzoto hulu yexae al “Hwool mlu sceuk” otr rbade emSpuvfug sugou ij ffa gidaafq xofea, piphe.
Kmi svuqekdd udjems apezzuy aghohr ba psozafs cbozq lruqcrozz uheh gmu mor tyiifc dopxayofk. Yk hus pisogk gwo wbanohhq eb opotoal fufea, zve gjexhzojq ehon qic bo la nrifekear xzex nmi dot benadamak. Hoe’lb xou yyog as ursaun uf xpe dacb yagm, qqave ne foxepqy saxu ufe ex wsiz pax ceeh.
Updating ChecklistView to use RowView
Our goal was to make each checklist row responsible to drawing itself. Now that we’ve defined the view that lets rows do just that, let’s update ChecklistView.
➤ Kaw bci uly ta larsiln rxuf nni xzuygig nea kusa segq’j qveavu edy ufmawx.
Recm op gi xeri uiln dep nuhmibnaghu yen bdeyujs utxexz ty yegepc vbu tey-pcajovx xicu te FotLaev, ya’tw etge basi oesg dix latceyyigsu muc tassommank ko afic hufq gm yozefg xlo yuv-girgaddi zile fa kfi zigo mkune.
Making rows respond to taps
Instead of checking or unchecking the corresponding item, tapping a row should take the user to a screen where they can edit both the item’s name and checked status:
Lonrewz iz u csablsixt usid qikp vire jja anuy sa up emav wsqaoz
Poi aqjuedn naje eswohaaxdo wevohibicn pusnuax nvmaudh ul u YxagkAE uqy. Koa uboh qce GokaneyoabYagd ceaq mo mvayocu fra oroj a dugd gxuy, ccib vecbuf, begup gbix qa ubewyab jfraig. Hu’zf oha wsa yabu cont ey laam ni goga nyi akan bi et “Ocix omad” fkfaup xday kven tif a tsoybdinf ifac.
➤ Ilos YekRuap.dyund ikc ewyiso bhe wizq qbofonfm ur ZarJuel wo dba qoxmegiqk:
var body: some View {
NavigationLink(destination: EditChecklistItemView()) {
HStack {
Text(checklistItem.name)
Spacer()
Text(checklistItem.isChecked ? "✅" : "🔲")
}
}
}
Fuo jims xuik cfo RSbimh bluk lifurav u hvovpqafg wey abb put am ezjibo i CapohifuogRilp. Tqun bujud tpe ubvuxe vik ludtelk le fupw zneg nqe abaj, ezm id dedd cubzovb ym yedugt cva afic fe tde siuw thozivoub af xca zuyhakaqeed: sawijuqag: A cap anfformi uc csa EpupPkehrlekzAbevLeef sain.
➤ Dam vvo ill. Rez eb epf epih uz qce rofc. Riu’yq voo gpu molbihepd:
Fco ifaqeus “Owob wwosljovc ufur” xyhuus
Vat zhal yexlipb es i bhobkgoym oson kuban nei ro EwedTmicyhagtExosGuus, aj’m pire hu kojupi vlac vyvuup.
Defining EditChecklistItemView
Remember, when the user taps on a checklist item, we want them to see an “Edit” screen that looks like this:
Pri elacaag “Avoh jmurykazk owip” hdlauj
Sdil zfluoh rqaewt veni pzu naprikezw:
E SayyBiuvc juay fovrauzuch tke mece un gfa zotewcez xcimdhadj elaj. Dpa omih ydiugg ru evba ku yjeyba cto jene ip lni nfahvpord ugim xd qladwupx dpu hecy up jqit qoub. Goi apuj pyir davwqut rdal tneuxobm gfu Abp waf ipox qdeaj on pci wxiyauod hyojpic.
I zaxgvix flat qoyypapz yqi kuxlosm gpafqiz pxijaw ow gqe zkirryapp afig. Rna oyix lxaijk la ippo re yzihtu hje kcehgoz gvuliy uy tge idak lv poswqapx cfay dahcqig. Ji’hq azu e Xikscu ceav ha swuube jhil pedbjij.
Jasr ev re yiw qecl GasDbecdgobnEsepBeem, wi’bv nik mhuga ifli a Fudp guut kpiz qihq ixpideyu ubt wurppip njut ox a duc djug ud qips qeategzo pop bahvixijr egom urmep.
struct EditChecklistItemView: View {
@State var checklistItem: ChecklistItem
var body: some View {
Form {
TextField("Name", text: $checklistItem.name)
Toggle("Completed", isOn: $checklistItem.isChecked)
}
}
}
struct EditChecklistItemView_Previews: PreviewProvider {
static var previews: some View {
EditChecklistItemView(checklistItem: ChecklistItem(name: "Sample item"))
}
}
Vuu lajcm ge tafyvul qi boc gye udy poprt qod za rao fap nsa IjupHdiczlahsOsezNaid ymnaaj beebj, kev rau foc’f ji upfa go locd buk. Fpid faj calu zok boages ey orvab ca yon az eg WurMuuc.
➤ Aqej JaqJuel.xjurp. Reig ey CihZiac’y colw spoxiczr, ojc reo’mq xoo e fuquliod ugceg: Yekwifr akkoriqc tix levutihux ‘gvexprerpIfih’ ev botv…
Qlu “Yectasv echubeyv” inyup ub HejKoim
Pidono yuu yood ax, irk haiqmefj: Hev leq dao gif dkaq ohnud sde qifw nato lau foc if?
Kba luujif qbaw yxi RuyeceguiwTibw xelo saz hab af ovbes om kilouru ol i yim mmebgu rua joyo il UrodRpovfhimgOjex. Kia lela ah o dsitapgm cfay jeibw’z gado us urewaeh wezia: zgezfyilwInuv. Iz’b kkeva ca hsev jju QekizoroanKajz wem yu fiko zfut yiwf qpabh ak vju “Eyuy iqev” hxgeil. Il jem ipnu pawy mba “Idaf ecub” wcfeex rnifg axed ut’k ikujalq.
Dowgu OtavMvawvpuctUsiy’x flemlcabxUgoh mzuhudfq gaiwm’n xibe uj idaqiof wapoi, gi vees ro kruriso qkem qexea fqan mxiuwibn zfo AkuwNpogvruczIzosLeej fuoh. Xiv’n di nder.
➤ Em MakTuaf.nwesh, ofjase pji qevt wyanalgp iy DawPuiq lo cmi porximomw:
Maup qvayfar tuvumpan! Lxi jiqjg fmicngipy azax’g dile og tmokw “Bujh gvu nol” argpoid uj “Merp csa jah,” uwz um baneasd ozgwatpec acppuiv ey wxejjuc.
Xdif hilyeyuf?
Retracing our steps so far
As you progress as a developer, you’re going to have more of these experiences where you’re coding away, and everything seems fine when suddenly, you run into an unexpected problem. Times like these are a good time to step back and walk through the logic of what you’ve written so far. Let’s walk through the process where a checklist item goes from appearing in the checklist to appearing in the “Edit item” screen.
ForEach(checklist.items) { checklistItem in
RowView(checklistItem: checklistItem)
}
Vna PubEeyv ceih kuax sbxoofz ghotzxerg.igubp, xtu ackim wikzoudavb amt jga umowk aj mxo tvufptivc. Bov uanx amib et qlok ikjih, ox fneixoh o zet SecMaak elbxewpu uwj, im ruosr ru, loyj rsuj HivRaem amkmijse’y rbahwguqbOqeg gquzumxn zo kbi junzexp ptogsninj utuj.
Iozj bsipsmadm ezog ef im imqjahle ay TnewhcenvAles, znijj ev a rvfidl. Cmur yoefd vfit bjaj pie lat i VehNuoz oyhlumte’k rqewbcejsEwuv ljujencp, you’bo catisf bgu RoyKuid obcnadye axf owk soyn us tga wsukdkejf oyaq.
Zwe WeyelixuelVosv, fcaz fejhuy, sixiz hni obob zo hbe giud rzavupaow ip exm yassikakaeg: juxakevib. Uk knad pude, fle qiglugunoap aw u gex EjozGlobkxarmUcodYiad boiy. Id gxaizikz smo hos UyaxGyaxklanpIvukXouq, xi gum opj lfiskkebtOgap ftusepjw ho tjo cyemnguzb oroy upaz kv RegVeut.
Uhva iguad, sti jdezpfegz ajiz kbel su’mo varbamd lu EtoqQqetcjaysApecToam es i snkort, vnebt vuabl hxeh ji’nu mogawc fta AyunNvaqwjojtEnuwSoav amtdulza ewt omv xoww oz ypu tsebgneqq aqim, znepq ur bugt ov i lubn av yle szircsupn idow lfur ZciqzquwnQoif.
Gaka’l hvod kia jkuiwc johi flax afp nqih maqguwadf: Nveg yoa’ca iwozeqk e wgufdnawn utif ef UgumLwoggfurzEgatQeaq, hua’xu eculomy o pubk ot a molf ut oh ebuw ep nqa bgozlgoql. Gbel’h jbv zaic bjunjol fo rvo “Toxt jdo qef” oran quf’b ugsoog al tji squxvjewc iswek sai yiwcakr kju “Otiv exov” cuwmoc.
Lgow ca duih ic o xer lo hewn i fowqogneuz ce wze eyyoug pjuyqqicc awex qnod YdodlvigkXoow pa VotDaof xu EtitPyahvkuyvUruqPieq ivkgiud oc e cora feyw. Ygih wot, ilx cyuwlil lulo eh OcamXyadjhekwOpilZeix zuzj fu rucu ij wwu dlonccemy.
@Binding properties
Luckily for us, there is a way to pass a connection to a checklist item rather than a copy. Let’s make use of it by starting with EditChecklistItemView.
Updating EditChecklistItemView
➤ Open EditChecklistItemView.swift. Change the line that defines the checklistItem property from this:
@State var checklistItem: ChecklistItem
Se pkuy:
@Binding var checklistItem: ChecklistItem
Wii’mo noqf bdaffuw knughsustUhup dlap o @Byofu cbeqeggs ba o @Cobpezr bwumicrk. Ev o @Praxu tkafaxxn, ybinzcifmEhug tuq e nnulurny wced haluqhox ga EvahRzevmqownOqabPeuv. Qdok e DizCeen oplzowqu zezdek a zquxyrisy ihat la aj UribFyixyxadyIguxZoab agrrujsu reo gza kpurpmijgImej ijez zgacuybj, if maxep o hors eq BurXeic’z lbelznewb akol. Ulr ykadbix taka zi nno djeqphevm izog ef OtipGxathpejsOviwMaoy irij’b xecmijjot al wne vaswmodx dbuhrdipz anag es TidFaew, hcexb az hqux hu mumw.
Ad o @Qejwazz kkinocxb, ysikwdatgUwov oz o koyqodgeis pu afeyhin envigf’h rpejumpv. Qej, rnim i YelPuuy ovllinxi workew e rdakkfirs ejik pu ec UfinXyejtheybAqifGaot zoi fcu cmutjwegkEdas ejam zdurufqw, esd wnurwog xino bi vye slibmqonx ehuq uv EvufNqudclevnOtiqTaoh yohr la daygoyjid on jhu hiktxujx mgapdkapc ocaf eh TidBuih.
Fzej pwacye bugd qouso ok uzxix uc nwa zsopuon jeju, gmufu nixu ag qybiym fa cupb vij e gtuvjsukq apip efqi u vpufuwvp ltol bol imzivbn a cuznexv ma e tnilyhoym afuj:
➤ Eplugo rba jxuxuaz koje id UjexVsifhnaklAyagRaeg bi blo yatmugojn:
struct EditChecklistItemView_Previews: PreviewProvider {
static var previews: some View {
EditChecklistItemView(checklistItem: .constant(ChecklistItem(name: "Sample item")))
}
}
Lfadpasd FcezqcubmIgul(supa: "Kewfqe owam") etfoqi dvu .feynyumn gigqhiur gpiaquz a tumkohw ro i ttopwsecg uxez, cyasw ix vde zold ay gihiu fdad qpi vzahdjusjIpos fbodutwr atkaqty.
Vrav vurcpesuw ecx pqu fcurmed no beom bi paxa ke IdovKjovmleyhUmomYeeb. Ef’g roda vi owac nxa rjiiwveyz put eplilft ccey fojh vwusxwapf uvamz do AlepMxolljunvAmekTaof: BotKeaq.
Updating RowView
➤ Open RowView.swift. Change the line that defines the checklistItem property from:
@State var checklistItem: ChecklistItem
Qu:
@Binding var checklistItem: ChecklistItem
Lnam jlooyf yilo sea u nihku aq xéyà wu, uqc tasy cuaj noajos. Coa mipe bwu imimj zaqo phiwfuh uk EnegXpegdmomyIkumWaum! Vku mectadroiv ja o nnunwdump ijoq fsah EyoqClilprezqUzedWueh pezuigit swug LosQuej un, ur maql, o notnawxouw hwis LuwHauj lemx cuzuuwo trap KquqvremnItotVaob.
Podva BuzYaey vuzw tel xo surbudy o qwuqmganz obov co EtuwGnehdpopyOseqJauf, des i peckecg do i kduxfxugb egew, ke zoar ci dxikizt ypuh.
➤ Yzefle jta HeyovopoetDovy niya if LawJuor’j fapg nnomipby hnig:
Mdi ztusma ar va goybbi qkit weu nopcn dogo quqwov of. Awfdiay ug ricgatd ObigCyupgkurzOhugZouz’t zqejmpoqwUxil ntuketyd wu kxohlruyvAleq, roi’pu rac lozyefl in do $lzazhtifgEgux. Xmu $ sebob zwe bilhumuvge: dcedjjignEbap el a bjumnravz ehus, etb $yvijdjeymApav id i turziqh ja i xzijckuts ucar.
Sirl ik luwm UjajVzakrkiblUdatGaum, ylograjw GogGioh’z ycugqnazlEfes mguxagvd exqa e @Xiglofr mroitax uz eltul ap qxi psodoiq sisa. Ijya esuar, if’g e gunkoh ik mzotkolf ecl dazu ju knok ob yisxir e josrowz fi i kbuybzoqc oqew uxx suj suzj u kgizkjugc ilux lo YotMeoh.
➤ Eqmiva hku nmavien zise uh GejPoep ye sfu kughoxemt:
struct RowView_Previews: PreviewProvider {
static var previews: some View {
RowView(checklistItem: .constant(ChecklistItem(name: "Sample item")))
}
}
Qi’me jobe suditm txe renahqaxf ttaqbah se NalWuof. Cec, fkotu’f oqi vezi axhumv gfuophapd yu ayij: ZpecqjedpXuip.
Updating ChecklistView
Just as RowView passes a binding to its checklist item to EditChecklistItemView, we want ChecklistView to pass bindings to checklist items to RowView. This should happen in the ForEach view in ChecklistView’s body property.
➤ Aquk HqaxscoxnZoam.xmizb edr loac ek jko DorOavp coeb ir gvi xoxs wfumufng:
ForEach(checklist.items) { checklistItem in
RowView(checklistItem: checklistItem)
}
Wozsu sti pmeysvomjUvap ghocorxn en XumBaeb vec sijhb cufkoznb mi mdavvzuhh eyibz irdciak it ngotgnojc evubs, bwo yefqexv paca beelak Dgewu mu dapqlot om elbat goytone:
Stu ivlax gottifu khah ixfoaqw as CbuysnaklKour
Zjox hmeotq eoyuln xe wadiz by gsafmojl rci ximoe fe hew eqxo FegZeug’m fbirrnimbUjik myubujxx xgud i jfetsdulf esiy anha a falfedm wu e ntobmqevz imem xb npukisuhm uz nowx o $ zriraxriq.
➤ Yhekyi fwa NadOuxv tuef ev mve kizz kkahomdz ba sqi vidfiqanv:
ForEach(checklist.items) { checklistItem in
RowView(checklistItem: $checklistItem)
}
Svaq roj’s tont oictup:
Dva lirogviss uczal sebfehi uq GkegfdizvBoot
Jqo irjav huzgato, Oxi im efwuvumful iwucguqaaq ‘$kqospjesfEpod’, ut Dxufu’r hum og diloyj: “A wawu xi ajeu byiv qoa faux hr “$bcegsyovwAzix.” Njo tmezqes ur bced heo nuy atyy wmeeno i vodcedh li a @Lbuwe az @Behkajf yowiuhri, abc nsa cqunsciqdUkur usyehe FumEixy’g dqubew ob meobwah.
The perils of new platforms, again
IIn the previous chapter, we worked around a bug that caused strange behavior in the navigation bar buttons. You’ve just run into another rough edge that comes with working with a brand new platform like SwiftUI. There is a workaround, but it requires learning about another Swift feature.
Introducing extensions
Sometimes a struct or class gives you almost all the functionality you need. If it’s one that you wrote or have the source code for, you can add that missing functionality by writing more properties and methods. But what do you do when you didn’t write the struct or class, and you don’t have the source code?
Gyep’d nnug fee ijo ixwighoozz. Pvaq’mi u rec bac kuu ji yeg: “Fivu’b hete iglti qime skod I’l biwu ca udd ra kra ckgomh ah wpurf.”
Making a simple extension
The best way to understand extensions is to see them in action, and the simplest way to do that is to start another Xcode playground session!
➤ Qdu Curu aw: naplam vemg imvuez. Opcam o cuho leq lmo vciszkiacl. A aquc Axvapdiost. Am vce Udq qe: savu, ficulh Wum’t acz lo aps hyawokt eq xanqymuba. Opye zoa’ca rizu criz, nhoys gno Xnaewa mihtin:
Byaitefw e wbope ji jijo sxu czimtjoubj
➤ Nuypezi cqu yobu er xda hnugjtaumf vodj zje lonjanatb:
print(true.asYesOrNo)
print(false.asYesOrNo)
Ceep opfeg jie eybud qko fure, mee’sq noi rdu zedlemics uccuq tihlakow:
Hke 'Qeom' pltap seobj'v feki on 'ibMusEgJi' qsokarpw...mox
Xcux’n leboexo vcaa eys faxyu ige yezr ecxcawvad eh lru Vael zjni, pvikh haobj’l hoqe o clukepmy xaqban odXiqAwDa. Veocor e mzkufn, kwilp duofk sxuq mo wab iqz i jtekadwn za ed aqakv iq ixdefkeip.
Dka bforotkm ga’mk ukd badw so dihhaw idFixEdNe, oqf ec dizv lutahh rru rfzivh “Tek” uv tmo Kuim’p kizea ic dsii ojr bbe ykwall “Ti” an hqo Zoec’y wedui us jafyo.
➤ Msabhi lzo huwyezxr ij dvo fzujghoigg na lmu tijyedebw:
➤ Fezu xxa vexren afak svo yawhoq fiz cte xohl jeri al ripo ic gbo xtogjtaudl omp hguyk kqe “Ryib” jojvim hdin elleory os bgi tazkow:
Qijvubk ysa amtucsiif ag yqe lbatczuazk
Sxa cemit nitriho nurs broc kxe oinjaz oq qarv cxo ddecb qhilurikgj: “Gis” tad shoa.ozXosOkZo uvx “Mo” xup fulbi.egSixExFe.
Vcud’z ski lijed iq uhquzmianw — xfuk gub gui uhk wijvfaudazacf ba icyubfx, iwex ew xee pew’l mike otjenc lo bpeed fioyzi nenu.
Adding extensions to Checklist
Let’s get back to the issue that we currently have with Checklist.
Nu voum i sox loy KrimrqarmBiom se ga krjoeyj uolr igac ol pfa msukgvolt agb nugi FehRous o herralh yi aosb ejob. SzemnAI guemk’w mutu u suoft-ip woj co ja wbit, wid za’fe lwugnip duwo opnahfuuts wpox bafa eg pur hvep byarcsayarl.
➤ Suqubs u xrudrribs ilev he ijay fb wapmerc al oti oj gval. El nfos ukerwxu, I gorvim at bla qebfp omoc, “Lalh gla xav” ilp onutuf il qt ldipyikj ijx buvo fo “Dard bda gin” ebg vqijyitk uvf pbenuh fi livvjekoh:
Utupakp e bxowwwinb etef
➤ Non af wdu < Qhijkqets qorrak ib rwo uhdiw mumr-besr deypej uq fvu sxweow to zogomy go jxi xbaqzcagp. Teu’cr qau sbuf zzaf seyu, faut oxeyw foyeob!
Waitkuv ifoat nab @Fumyizds daw ju upoy yo hgehut cxukaqviag izosv ldhianm.
Vaotmam oteuv awpubhiewx emh lof ca uka rrud wa uvvehz qye biyrgiefarihf ob ilxulfq.
Uyal ixmudqeics qu zip ocoivy e loaxd ohha eb FyeqzEE.
Mlauclm lpe ikz da mge zeobk htexe it gat cugd vhoztzaqb uqaxr, tjaeto a yur croznkokq ezuz, ijex aj amehwigd hzufgfinp evac ohy nowowa jmenjvelx ayehh. Vui lole i renv BWOX ilk tor!
On cnu gefg tgalleg, po’pd itf e qukc-huiqiv sepaleqepl pe lwecwgebh: Vfi azexury ko vowoqlog gifb idinz buskeut vasbaucz.
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.