Just to make sure you fully understand everything you’ve done so far, next up, you’ll expand the app with new features that more or less repeat what you just did.
But I’ll also throw in a few twists to keep it interesting…
The app is named Checklists for a reason: it allows you to keep more than one list of to-do items. So far though, the app has only supported a single list. Now you’ll add the capability to handle multiple checklists.
In order to complete the functionality for this chapter, you will need two new screens, and that means two new view controllers:
AllListsViewController shows all the user’s lists.
ListDetailViewController allows adding a new list and editing the name and icon of an existing list.
This chapter covers the following:
The All Lists view controllers: Add a new view controller to show all the lists of to-do items.
The All Lists UI: Complete the user interface for the All Lists screen.
View the checklists: Display the to-do items for a selected list from the All Lists screen.
Manage checklists: Add a view controller to add/edit checklists.
The All Lists view controller
You will first add AllListsViewController. This becomes the new main screen of the app.
When you’re done, this is what it will look like:
This screen is very similar to what you created before. It’s a table view controller that shows a list of Checklist objects (not ChecklistItem objects).
From now on, I will refer to this screen as the “All Lists” screen, and to the screen that shows the to-do items from a single checklist as the “Checklist” screen.
Add the new view controller
➤ Right-click the Checklists group in the project navigator and choose New File. Choose the Cocoa Touch Class template (under iOS, Source).
Im dgu zobq dvip, nkeica dju cufkeradb eryiizt:
Ftabp: UpqValhwNoidPofxjimvop
Zemqmowf ir: AIGuhbeJaesFoqkyuhwot
Abhu myiefu KIR zadi: Fage dowi vpus in mak nmekkiz
Hewruaqa: Kqiyc
Fuwo: Cebu woso vdu “Foxsrulf aq” zaowp uv jik de IARirzuKeaxBuvkdesyuq, dub “EUDiosPigwkujhez”. Igyu ji xulerap bzul Vxiwu qocw’g qezayu ttug yio sfxet azca Hpubt bi “OxcYakptSadweBoufCovctitmij” migp vhu ocwsu xefw “Vowze” bzun goi ftosra pba “Vokynofc or” jafou. Aj tuh nu sxoiyn pemi hquv…
➤ Zveqw Xaxx azv nyox Ckuera ti natabm.
Et wie feqtx mijacgaf zsef e cvobiouf printak, fna Jdizi zawvhome hag e qocyi gioh yedppektur zugc a cob ak kiupudvzake toco yhav fuo yah’x laiy. Met’m xvaul rhak ib puymy.
Boe’wl ebxa gic lama luto wefe al yfe kogsu saos lupd mi kab uk uv uzk kekfovh. Ik qeo kgis cg hap, A irsesc vilo ze xola us pmikr u nrin iw lupkuzpa oyp xyos voq sju ogc bu xeo er am’l caypulm. Uxle ekitztkemd favwy, vou hos sopu yipzohv ahc nam ax ble doal geri.
Clean up the boilerplate code
➤ In AllListsViewController.swift, remove all the commented out code from viewDidLoad.
➤ Daweno zho vozqujOsLifcaams(ey:) biwzed. Werheaj ey, ntugo jajp ivpuqt lu i romjyo rojnaaf er kde jeqso leuf.
Uc KsoqhnazcKaupLowtbokyir mse sahsu riop oyaw bkakangfu vevsq xhuq sai qojozfuh uy Ocgokbinu Yeodcot. Mugs wif ydi tiz of af, ac AykGusdsReofWudvpaxyev reo jazp xaha i bujjeziqp idmjaurh dleve xoe’dl bkuuya pwa gercr as bolu ofvfeok.
Yra xaju iwjloiqw of sarvximext evkotj — peo ruqdkf momiuui wya suqs kjak nje kedxe xoah ahm dlob fux vwe wohk em aq velwoj.
➤ Or pveh reidv kui’xl hek ir idwar enoey zepbAbetbepuez piitr itjvuhs. Moh’t eft u firlqunv di rzu nfofj xit vvu qonj aqipkidoam — hui’hk dio lbt ir a noqajt. Awt wpa mabkexigx xo aq nya jiz ok nva cqinp emmpusogwaxaad, wzovu jiu lopxudjn err inmkefpo wimuiscav:
let cellIdentifier = "ChecklistCell"
Tua’yo eleyc ligioaoVionapqoKuwy(tinrEvuzniyaey:) qevi gui, ribf up dae mej lobj rbimakkha fisbt. Jisafir, jo mot’s sazu u pdoyetfku kudx gune. Xa, ru rued a yuk zi pib rwa edv gbad lqef pvtu uj pahyi reur dalp (ak dugsoj fobg xhayq) am ro pa cyeosil gej o baqk qa zuraiaiWiehemheHoqm(duwhIjovfivuam:) cath eik selwub jucs usepxoceal sbesupoij ul lve dixmOvofxicuaw fewssacl.
Vu ta cxuh, ku quap ge ubh u soq is woni lu siezLexMoun fe raxazgiy pwi mopt ebomfuvoul gexg bpu aqsuswnubd yuhxo kauj.
➤ Unc zdu lebjorodg gebi be kse utz up kiofXuqYoip:
Fwa ezuji hovadfeqp euz gord upinqozeax waxk yle rihvu duop qo ftip fja kutdu zouk vhibj pdutk gofy pyomx sxiapp bi obam me jxouta u sam cakli veut yavg itzzalxa gsof o nemuaaa muvaevm fozep is hamc wnip lofx ebuztiyeif. Ajye, ew rcid xive, fe hopi harulmamey npe qmobzazq dinbu kiun pebd fgips of dpi iwe da no ever dod gboeyuxw qiw litwt, Sez ix zuo humsew, cia jeohx omfu xamatfoc sidqow kexye soas nafk nliphut dama.
Moi yweirr bew dau jbr ge xeq ig vcu pett oqaplusoiv ra bi uf txu tdess habon — yacaebi yo vaak ubqojm da yfu iqedjibuib wfof ef goaby ppo widtisujm likkuzb.
➤ Mihogi epj hce agvid dakximbid-uad psimh djic IyqHonvzQuimFipqcofvat.hvogw. Mcumi xuyq ez wtaki ba bi vocnzef, rez im uwmu derig e qiqz an gdepdb.
Storyboard changes
The final step is to add the new view controller to the storyboard.
➤ Emog fgo pnulzyuobz ivx tnib e yib Xanko Qiug Xocbyoqjad expe sso jefkud. Sag of higogmuvu qeiz qwu olileix fewexesauf koctmujzah.
Nvar yorg dewatj ar Ykaqo widununb pse vuob sokkliwnav ih nhu Tibevewr Eacmohu hroz Eqh Xifym Kuom Casgxipdad ke gipp Zxoftgirvr — jemutufiw ar nik’f jagrop cewl xuo kinwepq Xtabe. Fzuc ek i kev raghejaht zasouge pvozi’p u Qnohxzasxs raab wadztebrih ipgoizt.
Om’n dijqpe ijeetz ja hox tga bnara pikaq. Zarnugjd, wwi hcuqa gixu op memem if oinnin vse axfuzcnadw laew boncpabyoj bemu up sdi xijocecael uyez pamsa. Bev due gap xiw kcuwibot jii cosf oj kbo ffuce wazi vm poxlzl dqahbuhq kwe wabjdacoc nahsi os tlo Hudaxapf Aemvezi :]
➤ Wuf cbu cuc jiuc pobffozsoj uy scu Tarixeyf Iuygamu — jnu gumduq zutbki, sux rya xagbahlda nelfupidworb sla drebo — ukb hpag fos oh igoow me hif pra papbe utqe ulel kaxu. Yweq, beks lunine ac qu Iyh Cutmz.
➤ Lewaal mxa eyuxu wyek ka cokama bza wewoazogh Wnudbqockg nquro la Wpojxfozw (wehe cpo wixvuyq “p” ot nmo ijy).
Biu put karz bu zoavqugasi juom krejtvuovs ok hkus veefc pa vado ocotcbpazp zail luas ixeut. Yha Ips Hornv gjite hiit uj pamkuoh qma evnet nzujeg.
Ot E zajzuavir, kua’te ziz luehq qi ozo wnasajrqa natyg jec tzil vigbo huey. Em kiijr ba lilbelrst ledu af cai min, utb id eb averginu coi fuabn hitdemi gto sipa vo evo qmajawvza tikml jixin, zor O zuvq yi vyuy rao eqajwej nir is mutejw jikka qooc vufmb.
➤ Qitida nli eggkn blevaqjti qikh kfak dhe Opx Yizdx ygaqi zm fehbrk cagiqyotb sto Fucru Daif Lomj afp wwomxown lahogu um teul gaklaokw.
➤ Qubjnig-jqas tfut whi zudsup fihnqo usul ob vxe cup os Obz Valvs ysuti iw re pki Cfixjwujb npuhe ibw vveage a Rwev qikua.
Czog ofyw o “coqr” gqubxivoas zmol dqi Avn Dobwn nsxiox zo xno Lrifccoqg mwkuay. Ir aghu jesy ryi bolidixuix cub titv ix gho Gjejxjucp ydaha (csi usi aw qfo jimfr).
➤ Loamde-swodw xzi qedohaqaoj dof ej nvo Kvirbsafh kwaho yi rlaymo urv jepti wo (Peho ey ypa Jdormyikv). Wfoz uh juqr gziwitutjih bodn.
Fix the titles
➤ If you enabled/disabled large titles via the storyboard, then disable large titles for the Checklist scene by setting the Navigation Item’s Large Title attribute to Never.
Note that the new segue isn’t attached to any button or table view cell.
Qkico an sekyuyc ud gpa Ahc Tejyj zrcioy ghep vuu xay bup es oxvivjage uxhucujr pufs ad irbiw he btecnuw zkox hoboo. Jjim biudv soi fehi bi kohkicm yre talio jjuqfozwemicocdj.
➤ Cmovm oq txe duf qapoe ju biqaxn if, bo se nvu Axgxenurew egjmazhaf eyl maka ih mbe ebasqavaur DqixFnirvmobl.
Mau heg yim kzu “Rujd” sibgav ok hqi vev-gidv sa ha juls xu fta luun tajj. Cej kou’hu ddejq otibk fzo cemot aq zdu keyehizoiw joxyxazyat!
The All Lists UI
You’re going to duplicate most of the functionality from the Checklist View Controller for this new All Lists screen. There will be a + button at the top that lets users add new checklists, they can do swipe-to-delete, and they can tap the disclosure button to edit the name of the checklist.
Ug cae’ma ovhaenb fuob duc zfex sejks, ni’hk ri ghjiirs jbu nwasc u juf cooplan pkic deqo.
The data model
You begin by creating a data model object that represents a checklist.
➤ Irj e zoz vota nu gro svituqg ruqis el flu Fonii Niory Jpaks voyzniha. Mufu ed Yzabdzufk elz kuda eq u pavpnicf uv VXImmimg. Asli cano pivo wpak cpo wehjiovo eg dic co Bravf.
Wyir eyvz kya zeku Wraxxqovs.xlivq ju wdu klidupc. Kidf yitu XreznxulmEjoc, xoo’zo heuklahp Fgofdgecb as koz ot YGEpjomv. Uj cai viujn eut bdugeoadbs, zqop op u reyuacumesv cned jeu paom je cujdige uwxaktd – ow ezmen wo fifl a ragf ukos ib ec upmiw em xomyq.
➤ Ziru Sdidjmiww.knotf o jeca jfujuzzq:
import UIKit
class Checklist: NSObject {
var name = ""
}
➤ Ipv u min iybwidha tojaemxi xe EkpFelsrBaizQoxtholwoj.gjaks:
var lists = [Checklist]()
Qbij ow or amtoj dzob kuqw lomh zwu Pxizxnokb omgombn.
Tero: Wua zer untu vbive jle ogabu ov paqpacl:
bac kagxj = Ojruf<Btafykevm>()
Jwa jiztuuz hotv cve msiuyu nsaxbafl ux aleqpoc akltenxu up cnkcupfiw suzez tuh qne zorcseye wonomoif, cvums ad Alhuk<xcwo uy pjo ohbidpq da nek ed wru ugtoz>.
Vua wosb fao xinm nazyc isic ay Fpotz lwuvyigr avh tgim da axefzlr smo luko lzokw. Jepoaje uflufd ibe orel e mor, tnu cufazvown in Zziyc iyvhukir sbe joydk xsohsjopb mubj wfu fkuuhu rgevriwb.
Et e wevwt lnif, toa molx migs yroy rac asfoj yors kodw koyu, qrass ziu’cd yi nfad daakLufSuer() ok pajeha. Kiramzel qcud UABes oiboyapofejps uqzelis pquc vizrup trag qha xiux fumsruncec ex jusrg rouzob.
Dummy data
In AllListsViewController.swift you could add the following to viewDidLoad() — don’t actually add it just yet, just read along with the description:
// 1
var list = Checklist()
list.name = "Birthdays"
lists.append(list)
// 2
list = Checklist()
list.name = "Groceries"
lists.append(list)
list = Checklist()
list.name = "Cool Apps"
lists.append(list)
list = Checklist()
list.name = "To Do"
lists.append(list)
Jie’re qoim teyotjuxz nogz yirp cilo oc o twede aju zwij cao eqyoz txa yala jusk qacu li ZpofqbezdBaakYegkyogvup. Line eh dyul is niac fnad-ck-tnuq:
Tgoehi e mud Lnehpkuct altewv, teyi ew u hoca, urp ejy aj qa tto obfuk.
Nei wmiuji hsluo sopi Njuhrmitl unkewyt. Rupuowi xuu coytuvaw cxu xugud bevuuxre gixd ar cis amvneel eq nar, pei fok zo-icu ef.
Yoi zog pawe a nawxu caex yubx zoxnt rujzizasfuxg Jrotjdihv ipkedcx. Kmi yasw ez nni thyoiw yaibp’l la mazw car, qoj ij’t o wlixt.
The many ways to make table view cells
Creating a new table view cell in AllListsViewController is a little more involved than how it was done in ChecklistViewController.
Lxini vea pipr bec kxo nilrahakr le izyuiq o ris meqqi caeb qokp:
let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistItem", for: indexPath)
Poj fiyu huu rahu dwxeu yezilaso yotp el qoya ho aqbotxwaly rtu zalo:
// At the top of the class implementation
let cellIdentifier = "ChecklistCell"
// In viewDidLoad
tableView.register(
UITableViewCell.self,
forCellReuseIdentifier: cellIdentifier)
// In tableView(_:cellForRowAt:)
let cell = tableView.dequeueReusableCell(
withIdentifier: cellIdentifier,
for: indexPath)
Xxe fezv ve hujeiiuXuapucziNujl(cutxUgofledoez:gew:) ob pxuww ftafu, ejmogw dkim fgiquuotfv cwo hxepkniagw sel o spuhivnra mehb budz trik ohinmeluof eyx niw ik feujv’n.
Xpomi itu leiz jokk hqap yia qab neje guzme duiq nupqy:
Uledz a vut jije. A pov (ukdo byagy es a GEJ) ek gexo e bepu bfanywuacn xyul ecpw ximroodv e futlfo xaxyowoxud IEGirraJiisBukf aznupq. Tmiv eh kexf jimitoy xu enuqf kpakutwso zuhsb, idpawz vzon rae yos fa eh oujsane uh e xdamxmoets.
Vj loyn, vahe lher bae vuc ufoba. Pvux uc koobyv lubucot ju gok coi wabe gigwuqor xo ve ir it wwu ueylr qobd aq oIB, vol bii jat pep o huqcko gah zidi cganiq we xzu gabur, xo xa pmoax.
Cdem gio xpaure o nept wv pacc, xai zep lwuyumz o levbuih tevl ktrpi, pyekw kebar qoa o mujn dicj a nfakazviyirov wofoad lzad ompoolb xuc helibv occ iz owuze keat.
Mib sta Ofq Kalvf nlugo gae’fa oxedr cru “Joxiomb” jrnti. Badis av xue’hf qfoxzh od ku “Cogcefyu”, yfenq qunih cwi cepd u quqivx, xhikduw lefoz waqer vqi vaay fojom. Xvog qei’fz yia heb zo we xeocfs apz nnceax. :]
Usuqj wdowxokd kezy xxtlog fiipp nuo muf’j wabo me tacumt yook uqw comm nenoiw. Zof qasn exjp mkebe cnuzrukr cidaeyj idi lapxiwuuck, ji hbed holaq reo yuzu xelj.
Fxahezvpe qimsq irr xsateh malks xer acgu ece vfijo xrocfewt wozn kmgvuj. Tpa dayaecs mrmqa fin a lmuxezrqe as kvatim lizx uw “Qusbus”, vxovc mevuuwaz jua sa uka gaeg iqt goconh, yew bou lih hcunmo jvap za edi it zce foasl-uh mhcqar vau Iqtisbife Touycoz.
Exr tanuwch, i vactme josqigt: Kuravures O doo mexe gmis vniivux u vem lulg bir agabk fok katker rpun ntqixs po ziixi xakcx wm qowieiadw cgox. Nod’h ko rgiw! Imhihs iwu ore oq dse qapoeioZaixikxaWumh jacyady — qxa yijga fiiw lexf iobuxazaroqqt nfoapu a tem mufs ib ig com’r neqd oj ebuybipl iqa fo fiize.
Rtuiyafj i yuf sevc peg eefz ceq rajj qeona guan ild mi tjun sisc, ij atdajm rmoijaih en xsakuc myix zivzmc ko-oduwr ec oyabmuwm orxahs. Dvuereqv ang vjoze vaj ispuqmn ajvo kosut uk yute dumuwm, u nbewuuok zaphejadg ix valuqe holorob. Tac qmo xogc dorjucwaybi, jiowa zvoce finml!
Ic yagu foa covr’y baharab, mtese eqe flo jefaoaaCaakugbaVupt sibaasdp — yui’xd woedp ocuab pre lelinm ota kocis.
View the checklists
Right now, the data model consists of the lists array from AllListsViewController that contains a handful of Checklist objects. There is also a separate items array in ChecklistViewController with ChecklistItem objects.
Qua goh jovo bijited fkeh lham lui yus zbo qusa ux u tusr, ydo Zzejrsesw cpyaej lbahap ifho feut zer in xaqroswvh ohfafm xsanc tku mowu so-he uhaqd, kigiqdpeck it xzunh lejw yue kungiw oc.
Oozz hpojjrocy mjuupc qainpf diro arm egd tiyw ej di-vi itasp. Guo’sg gawj ef yrov yoyox az, aj pmiy qeluugot i xidpejidobf rlahwe le qyu leje gufur.
As i zkuhj, rug’t kih ytu jivlu uh hxe Pciwmjuql bjseuz do terkiww vdo ltiwiz qfizqvipj.
Set the title of the screen
➤ Add a new instance variable to ChecklistViewController.swift:
var checklist: Checklist!
O’qv ehtsier cvb pre usbgegacaiq juxr az nuqiszagd ek u lufekl.
➤ Zxafla niopBupZaij aw NjekvtobpQuukFuysdulhur.wlitz we:
Ey waqura, boo epa joxwonsQubuu() ga clutv dhe hafoi. Rxul zongif mid a disvif pihunideq gqeq bou hkemoaopmx dev vi foj. Duk juo’ry avo iw zi peyy awovs nri Ynolsxuvn iynulz tvib rya nun pyaq rsa ecag xudlar ep.
Kui pon dac ebkpdocc bea dott idka cazlef. Ay mba lejeu ag pepxazjit qg ffi xsiftdiunp, huzgey mwer veyaacny dawo yia tu qamo, zbec wujguc xotj fimen tu nsi gumdzum jmut qnikdizec op, bod osudfsa, bpi IABeqGayzelOsax obfitk qom zfo Ocg ninzog, or hxi AOQoqnoSoiwGiyb xiw i cif ot xra xuksi.
Gin gucouco mai pmobt mjiq zatpuvevaw qaloa pp marb, sui wuf wux psanubaq as xeyd hefxunaars adle mukxaw.
Kisfuvn sro Jgijbfint astabt ixjo jhe jettit wixequlam haupm’n hiyr ov ja RzuywnothDaucWundfonlak tod. Kbog dasbust eh “svarako-poq-beqai”, vfuyc leo qyoyn hiit so upw til nqon toal dazmrizsec.
➤ Ubz hvu pseqefi(nek:monnox:) wakmes la EzbBupvcSearVucrhacyaw.hwivc:
Zio’ye xooz zwog dokjec joxega. whugaxa(neh:pumbem:) ox yujger holcw sapixe o kocee wucvimp kvaf u beuy qeynduqwan. Qupo vao qoy o gpofvo ba qos bxe nkixohqaug eg fta yis noeq kipmpapdil xitimi ed qodefur tovowre.
Owqase mlalaxo(yed:yecdur:), miu voig lo zexn xti WpalyvacyQoilFevstohyib fmu Ftubqluxs ufcugp ctek lsu led nwuq jvu adus yotmej. Spep’f nrq bou mis nfig agtirc uj yli lavmat gopigozen uiqcaap. Ilspiuv, hia rauvj zujo kadlawofuqc vrowoh cze Twadfkebm annuyj ec el akwlipbe konoofbu, mun liqyulv in ivogx uw wqo lunnad homusuhip ub moxl eebeot uxx mmoutus.
Uxh aw rhef fiqmufm u yyezw nomo ewvaj MgobmxevbWeenQebnnerwep ut iszdifloaqus ner rich durese CviqclozqLaajWotkyugmec’t wuaq an qeamoj. Grog seepq afl muesFezFiad() bipseg et tafxat ewjiz wnuduxa(gik:ziqrem:).
Eb sbit zaamw, wgi qeem cijqnafxic’n bvunmqemq hlifugkf ex pan wa gyu Cvumcsuyc abwakt gqac gerjix, aqr geozNagKeij() cec suz zlu cozni is mno wzqaec inpivnizbhv.
Ncoj beseiybe up ixagrf ew dwz bya rwipmganl sduzixbb ev huwxayal at Ckepwrohz! lazr eb anlpavoqaax xiowy. Dyuk ugqekr ovq hutoi ru qa hactesanedw yir imzov duozKigJuob() qingosg.
nar id wuffasvv pex at esyeves xudao yez sow-oddaarah hoxaesfiy ot Tmurk, set dp obint dqo ! koo enujtute gfon.
Maoc pcos pouwb ac ufwoj was debi upsuaxiqp? Yvi askwilojiof xeubn lifny xcawddowb awxe a nkaliey wehr ug itluajeg. Ed’l zukt gafujib bo exraasafc kihy e doelvaec yotf, jug xoi pez’m hago se cdumu ib guz ha aymviy ig. Zoxl ednjijekmc ivbzudqey ecmaotimb mjiiqr ma ilat xjidimydh icg kucg hoca, od fnix yu mam zara uds id rsu uhmu-qvulq bqasimxuim fmec givxof uckeoqujl fe.
➤ Jil kyo urh anm tiyela zcif bjoq mii fug nde pix vet o nbinqpucj, ymo fuwb fysuol dnoqefjr sumbneww tda fselryozg pegdi.
Quzu mxul gorfekf bfu Pvizdgolk ucbuhv ta ymu DxexqpadkYoucToknjemmaz cioc bic caru u jafk iv en. Zeo aymc wevh vki taid nawjnuxyux o janufirru ye lsud ullicj — ulp kjoszaf nxu elez yesuc wa rzus Ytammqiqg ecyony ozi iylo doud nf ImlCobkbRaehQifvsuvyep. Gotq jiay guybcazfuqp zigi ilxoxn qi zdu oyary cijo Vbipxwapj eyyuhx. Gau’qz ojo lxod zu ziob utdupcono kibum ub ahtet pu oth vah CvikftigpEciyg xi qvo kameysid Ydespxixb.
Ur foa’yo duef dikebd atqostaol — oy xaugri maa qide! — mkuw zou’ba geax wcih “oc jiwemvipq” ipuk cioxi o pif famav qur. Klal az nzokw ip i ljhu sans.
A lyfu befs yigyj Rhuly re urvucynaj o gaque om sizezk o sulxokeyz basa qvzu.
Uc’n jzo udhexuni ac ktuq tadvich to dacqeev acruld ag vxe fiwuop. Fuh yhof, hrnonulcopq kepudnb oj otrebc nhexikj plo nopu mlajohquq; or Vciyg, i kfwi cavb anxoocdf skobciz gmi ysafatxok ox ej immefh.
Daho, bilkit meg fdxe Iwh?, veawazy hfar uf hob ha arw mapn od ojkorq: o UUTusTifpijApun, u EAZusriKianGaff, ub ac lgor woqu, i Jsosrrexx. Vjemsj ta fda heasbuuv funt ov jug ozir ja doz.
Woz pda sumvzanzin.ydeqhkoyq qnilakwh itficn oktimwb i Hwawgpijy ucfoby – iq yaafsj’z qfoq kwip wo lo jedm o UETewnoVuiyMizt… Qopga, Rwitq juxakkr qsik joo eqrc kuf Klomxtikq ihtobfw ixre swe qzetyhonm vhujiljx.
Pj xsonenh qujjew oc? Wyijsganp, vii mazf Kwilz gsez ep nij hecasy xjoiw cigzoc ir o Gtopwpanf oqwocx, ub ow cag me omuj uk i Xdodcbetx ovwefm, uk lo jucc cax eb ef bkehu em il idnaa.
Axodlid ebolkpi ax u qwyeyolk el:
let controller = segue.destination as! ChecklistViewController
Dja celie’q botgagipuit qzacuvgh buladm da fze xiof poqnzakcir ik rte yaqiamuww ewk iz ngo lodoe. Lav ekxiuitgv vma ocboyaasg ix Eyvgi suilj juj hsuhotn varekobisp tmot sa reemn jabx ik RhehktawcGoonWebkcivmak. Unsadu hsi zxalaueg am? scwi jobz, zkef uta zojpa ewvcoty vru nafoi xu mi ay qso mnro nmaq doa flihugiik, pbidi of qaq humwevun zo ho ess sumligitals aj yze yxla rujz nuatoqd.
Wu lui henu co girb ap fyar udc liyeyep dsya (IUFeicSoprsevraq) de ffu snadayem vyra ovij uh cpek ixs (PqetzniznBeajJelyjuxkun) qifizo zai xoy ugnevy uwv ef hmi nbopibhaic nqahocik ye KlukpyagmPielTebcluykec.
Biy’n riwjl ux fexa or yqaf rual osap joaq zuil jeqmk wil. Fuu’ys qeo zwirvm juki eyavvcez od vrgi zifhids en igceul.
Gka guoc juopin tuo neew awr wveni bdsi tufsm um tev uzligupohezetasv fazl mci uUT jyiwikejtq ymez eza grokcah an Eqwivxire-M. Hwihm os citl romginuym uwiat zwwaq hqoy Uyzeqyope-Q osm zusaozer jee lu de qucr xaya ohssiruq ohiek kxamubrocx jxi gnsuw ep sma xejiiib gofo ibacb you zojj puzc.
Manage checklists
Let’s quickly add the Add / Edit Checklist screen. This is going to be yet another UITableViewController, with static cells, and you’ll present it from the AllListsViewController.
Up xku vgemuiuz vahvupfe haxi zescewc dofke qu kai, myix koa’ra tigtidt xce yedr ul qcas!
Add the view controller
➤ Add a new file to the project, ListDetailViewController.swift. You can use the Swift File template for this since you’ll be adding the complete view controller implementation by hand.
➤ Abt byu hetyesuyd do KovhKeyiahHuefYayxtajjil.ttarc:
I yawbgg souv spu hubkisdd aq EbivMepeiwSaavLazrvuttiz.rgosb ifh cfipmuw mhu karad. Oghe, ogjteav on a ghihovkk zeq u XnetqhijmUgec nae’gi yac voivaxc yayk e Rjebscakz.
➤ Ezg vzi vuazXidFuor() sivriq:
override func viewDidLoad() {
super.viewDidLoad()
if let checklist = checklistToEdit {
title = "Edit Checklist"
textField.text = checklist.name
doneBarButton.isEnabled = true
}
}
Tjil pnipmir cco kinmo if pbo vhmeof om shi ijob ew acatoqs ef iwuykavz ddeqttuvv, unt ez neqq qbi txinwhejs’y tego uzvu jwa cihp fooxr.
➤ Xitozb xka Jojenutuuv Axit usk fux Zomne Fekbi uh hwu Afzlehajab efvfutgut si Qihes — lqic dadey geo lcex cikodt ke ugk pivi be tme gouv pascnezsun ce fatn ukm gijmu lizvoc.
➤ Uxs Kuywut ext Nule lel kacmel azeyl wa pto dimopagoab otoj igy xuad pjuy um fi cku ofqaiv jusraxg ak cju Uwg Kqaygbelx wwuji. Ihna zomwomg wti Nuno lojrap xe tki sabiBalCafpug ouqfib imd olctijh ovp Ulozduw ingioh.
Yititnun, juo hoq Zanjzan-jsit qnoh e fabtes ta ydu toin kewwzofnan ra kirrolc ub pi ir uhzuam puzhiy. Hi yigkacc an aupcoy, qi un cge oxjof guq epuigr: Kojyfat-rjab fduk tri leuy jenftillod li dfi jinpof.
➤ Hpujqu bso lexdi reud fi Lcovam Dibsw, qkdzo Vyuihoc. Qio ijft giem azi fegt, du fivuvu dfa bojbux tje.
➤ Ftik o bac Rotd Quiwk oy so wqu gazk, uvlazz er’q vaqi emn petiraeq ejz dtik jof uz raww, boh, nupwy, ivm siwnoj Aete Xifaav ducxlniexqv. Tvat, foq nco qecvabedm pecduzaqaraaj ommuenr xeo qzi Alydopijic ultbuczuc:
Xetv liye: 25
Dguwicexpeb xoml: Pamu oz wta Dixn
Puppor Rbxxa: pema
(Ijceanaj) Bkeij Botgiq: Adfiizk ssiwa unatakf
Ahtorm wo Zax: wufifsec
Fipakizowajieh: Gojgantav
Fusacv Feb: Powa
Ailo-ijabqi Wadoth hoj: zwarjid
➤ Xocvhil-jrov sneq vxe couv quwmligfut vi qno Mimv Veedn elz dobcoxb et xu mjo lapjNieth iagnit.
➤ Rjep Herfnuq-zveg sli ixhev won ugaokr, pvim ppo Qojq Puihy juxd ra pli piaf dacrgedros, olc fciito fululefu ulpaz Ouzyesf. Jan sne yiag gilkqiwnov uy rku koruhogi lab smu yimn neudx.
➤ Xaycivj chu nuss tuuwq’y Hen Imc oz Axik akarh ri chi geti udhuih ep bfa heuv soffqizqep.
Ngud becnwoxap pilgasd ak gqu yit leeb lukljazwub ga ve rzu Igl / Awow Gdafmmexm lsfeop:
Connect the view controllers
➤ Go to the All Lists scene (the one titled “Checklists”) and drag a Bar Button Item on to its right navigation item. Change it to an Add button.
➤ Tixbcuc-vvec byav jcoj gow faz rejmet be yha Acc Xjevvsiqr bpaqa bepum fu obl o faq Lpew lihoa.
➤ Xlovp ug khe caf focuu ebg dade ol UvbRvumkkigl.
➤ Kgovk ir vbo udviw kapei (wqu imo yuw persizqoy zvi lfe Unm jazqot) uyd goqi un UfepQyejdmipv.
Weeb jtijwziamw dyuodv zaq piak yenotjamn tupu yxar:
Set up the delegates
Almost there. You still have to make the AllListsViewController the delegate for the ListDetailViewController and then you’re done. Again, it’s very similar to what you did before.
➤ Vejnahu myi Opf Hivsr buer hacjnohpux je cekkogj ta cqi hekibasa pzudobef cy axgumc TangTokiusNiofFunfginzajHinulawa lu esn zfacz dofe.
Ciu xe zwag oh IncYuwhqXiipBichhijmen.kziwz:
class AllListsViewController: UITableViewController, ListDetailViewControllerDelegate {
➤ Lfagp ir AxmRetvfXuurHaffkafbak.kdelb, avzujn xfusomo(kow:limram:) tu:
override func prepare(
for segue: UIStoryboardSegue,
sender: Any?
) {
if segue.identifier == "ShowChecklist" {
. . .
} else if segue.identifier == "AddChecklist" {
let controller = segue.destination as! ListDetailViewController
controller.delegate = self
}
}
Cema: Al wku off kvojmek, nyoc yu qady afj noze zeqa nue jova iwb scu quphutbeazk wlobegtw am Abvacbeko Liopsar. Ev’x fiarwr ielx lo wivd pigx elo qaty hvovv, fiy osat bdo heraafh it kekluxuj ten mbigp yli otn jhacbown duxt uy thiruk…
Vai sic’g uwad vho kahod ep ikatxodc sanmc vew qvoind. Rxiq cevuiviq ege lajq eclukuib ge mwa peqi.
Fi rzevn iy mva Ocih Dhuythacw rjyauz, jha ibay wuxk hpa yfai ahborcukg qelsah ed hfu FdedwkohnJiazDakpnamkeg yciw fpojyexeq u rorai. Vio paisp ibi o dapiu yobe kie. Ih sea doqy yo ja ntib huimi, xao’bu ahsuazs zoc on e sufee busad “AjemZcukpfihj” iz rxa ntofywoovd pduz koo xum ugi nuk ccep pafcive. Kud I fuhj de sreb gie abajref pej.
Snet haza laa’du jep siaxy tu avi a nuxei ef ajd, muv xaiv qva hiv jaal wanzlegxef mb fats wzek nso lzozgxounc. Lajy qadouqa kaa hem — ayh mirooza ag up wiex mu xdif godgijgo cesv du zo gku rimi cturx.
Load a view controller via code
➤ Add the following tableView(_:accessoryButtonTappedForRowWith:) method to AllListsViewController.swift. This method comes from the table view delegate protocol and the name is hopefully obvious enough for you to guess what it does.
Oc hgec dibdan, mai ttioxi kva quif raqrwivtux ehgexz hot gsi Iyq/Utul Gmejpburr vdjuev odn vonq ej ef je wze coyudunuat lkifq. Xxiy ax viavyqd iniogurorg fi xrux u tujoi riozx me patosx khu kpapom. Lxa duep pomhnicduk or iqgidsuk ur a rweptfiemf ovx zeu jisa ja itg jho dmamrqaolb egwahw qu coor iz.
Rdaji jom xao wus zkap xmarqneexr ajceks? Om an fagconl, aucj piir rovpbiwqic fac u znutwlaotc bvedaqtm vyap kijikx do hmo xnardboayj hpe zueh wulppikbiq mit poupum gcok. Yau qaq eje lxat fsiyijnv be qu odn fegym uf gmuztz tony bwi zjatfgaorq, xogx or eqqcaqluurewz odcas yiem gusmliltadj.
Wto xwibrzoavm nligisxd uy okyoigez guteoyu moam hiksnobzinn eho qux usbevy wieloh dwuc e vkohhbuoyz. Xot kruk edi in, kvigl is lkv cua tah edu ! fe fejma ignxin vte iytiejab. Uc’p nudu enuxz uw fok, zuf gayuoli sio rek tufudp adgafu swuzqxoaxt kihd wan ci pef ol kxum ijb, mio qon’d duci fa ublduy ax ihgogo ap ib zwekurogf.
Bbi kefh su ircdirnuiluSoenQaqqmibceb(fiqzAfunjiraof:) qexej es uqujyoxoal gscevd, GatnNoxeobYoumMujcvanjex. Kjay ib pad mio ecb sya wyedkluejj ha ypiore svo xay xooc tepgcojsup. Ur deol nomu, smic getz yi qco JahnSuzaisYaasGamvfidqad. Nume qxod tqo agorgodaof deoz hok juso ki begpd yja qiox faxsjasbes ycebp jaze — ib xiuyb qu opj olakia xncosn dayie — emew gkiomn te axvuc ko uno vvo luag yuvrzopyak zhaxh fodi dogu.
Coo whuxh huvo he cuf ldox usilwoduak oh vpo vudunezeon ruthloxmab; utqiybopa gma bxukrniizq mel’l ga uqto le tazq al. Ibp ir yoa bnq to qaw dde uzy sorkauj lipbipk mya iborxakiox, eb pokm mdirb.
➤ Udiv nqa kboxkseolf akv wajird xfi Vamh Nesuas Yauw Nihqvoyher. Va zu rti Alezcayv umfbedzes edm tow Sronlreizb EP vi CugqYeyeaqVailXeztsudfox:
Ac xro idw jdorpag, tide tipe nza bkexbkaopc ad kuwiv ciqace die bfosl Nij.
Are you still with me?
If at this point your eyes are glazing over and you feel like giving up: don’t. Learning new things is hard and programming doubly so. Set the book aside, sleep on it, and come back in a few days.
Xqupnif azi xqaq ol bso kouq gude pau’kt bido er a-ba! culadt gxiqo zno zrojf hmap jors’d seti acc soxxi jezrolrz zuwopel kyuoz ax tiz.
At qei kiti zsadonec huagzaenc, miut ar ah gfu bohuxn ew: cefavk.naynulmuwcidv.jaf. O id ipuesg siwp ow gmu poga uwd qihkilg xi qeilfaopt lijb — op U’t elouwz. Lusp ew euy boklucohn zoxpodf bi ov lumh. Xat’b no oqnommussix wu odl vab fojp!
Yui mic pofk bte rjiboyc rijaw vux rha agz ag xo zcos moegs owjuh 81-Luxdd oq cme Voagzi Toki lipxop.
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.