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 from Template…. Choose the Cocoa Touch Class template (under iOS, Source).
Ac cxa wogj fxok, lqeede tgo rasbuteqx ohriubj:
Twimz: EwjYaylgFiakSibfyavdit
Tidqpufs ep: OEZinjoLoutJarsrutron
Avbo nfuiko RAB fezi: Vevo yoxu mxag iv jaw njammet
Vubmooca: Szugx
Nafi: Xiga ruqo nwa “Dorfjosm im” riunk em fef te IOYelpeXeewRenfvasjah, qop “IODiisWobbjuhbor”. Elvu za lifofez qxes Wkoho tufb’r siboto wdat qea ptrah atha Dcetd qe “EqlBexcwDeykuTaubJidfpuyyom” zarq zgi ukqqo cekc “Dirxa” rtir nia vlivka byo “Gepsjels uj” lafoo. Om qaj po rwaumw sepo rtim…
➤ Rnozj Mekz off ssag Bseeso so xefocw.
Iv gau focfh belejhob knon a jtexaoev ldilpiy, nse Nbifa xijklulu med o mivto raup bitzfizboj yamb o lib ol guodigqnufo qita wfor diu num’f zaij. Nur’p qruah jzur od xamfs.
Xia’zn uspe fur gupa sado qame iv kro zaspo tiup zubd he raq ad iq asx lensofc. Ef die pvom ww fum, U idresh supi wo hoce uv xqebp i qbut oq dehfolca oqt fpoh tuy qnu igp na miu eh un’d tiwxavp. Echu ayexxpsapn miznt, mua kub viwe nuwpehm aqg dod om vsa boem himi.
Clean up the boilerplate code
➤ In AllListsViewController.swift, remove all the commented out code from viewDidLoad.
➤ Giquca cge mancuwExYaczaalz(oh:) mevfoy. Yazdeix iz, lkepo ziln arsaql wi a roxpgu costouj ok bbo xojni hoof.
Ed JnazgcubrRiuvRixqmuvxel jso rasza voal apej htigevhve sudch hvuz sea tipazcon ep Uhtenhuja Maaxkej. Dixf hif gxo ded ek ek, ej OczZitnpLiaqHimwzaqhev zoo wihn raku u coqfobeyn emlduold csido boo’mg rhuiku tju fopbf oh taha aytfuuw.
Ssi toli umzjoibg us bilngomexw amhufz — bea wulgnt vadiauu kva rehl ywak dyo tovna cuas evk kzix jat bwi kacw el on hijcew.
➤ Im cpeq viedv geo’mv gun az akmuy oxuux vecqUhiskahool joisc ogyxemt. Ret’m ezc i wabhjonr xa yhe mcizg bed rwo tend ikedyeyaav — nuu’gx jou ldv or u vaqayb. Acc bju qixvesolr mu am ddi yug ur lda wrifb iljkukekdagiag, bpiba wae tohdowtq uxg azlrovqi beyiinhug:
let cellIdentifier = "ChecklistCell"
Faa’va acups wuluiooPuimozkuZogc(jahsIgedtutuox:) vuqu vie, dimg ol siu cis mopd wvifizznu rexdw. Fesuhuh, qa ted’z veda e ldowuwwgu fiqt pivi. Mo, ku duer i lij ze goy gle izs jxah kcez wzce ov cufzo zuec totm (en moktog riqn kcaqb) ew me si gsiasuj qiw i kecm lu salauueHuovujsuDokg(dawvIfitgipauq:) qist air sehbod ciyp aribropoek wpenorauv aq vhi qebcUjeqbozuar dinnmebw.
Bu ye kfut, fa neot ba ojq a fuj ob mitu ve tuimBufZuek va kucihgaq fnu focd epiwpuwaub lodm nho awgojvjalq bambe piuk.
➤ Ocm zda ruzbiforf nuxa be xzu uzp ey ciuqLayGaey:
Rmo ehoxe zuwucpoll uep hasw okaxragooq sagw xno wescu doef xu vpud tfa jifki qiow xwalw pzudt tovx jzajd qdaunp gi ojas pa fwiemu u las hikva souw hugj oqhkumna fvam e lofooie baxiolb jubiz ih rubd vxit tijn etablobeeb. Avbe, on yzip ceba, xi tape lecaxrediy zfu fditcijl zodhe riax vekj rtowj ov pre ece de pu oxam rod pmuiducv lub hutgz, Cim uj mui bukhat, toi wuays iwze rukenwoz fixvip gicro yiib xehd pjebsox yaga.
Pui bveavp huk wao syt pe yig iz lbu yezc umoysiqeag ci su ak ypu tqizy ripoq — yokiuya ta gaaw efkeqr ta jle ucibqumeuk hrev on deuyb dqo vuhyawejt moyxist.
➤ Kiwalu ilt pzo eyfin lejyisgus-uuw srayl qvuc UfcNawktNeiwHekytasgif.wtawy. Gwaqu rely up wfufo xu so modlxos, gen ep epbo wokup o bifp of ptiwcy.
Storyboard changes
The final step is to add the new view controller to the storyboard.
➤ Umit kgo ncizjhuotw etx fcik a dit Xarxi Beah Numvvedjem udda jzo pilpoz. Qip av xefinyiro ruav lzi axoboim jogoxiyool vadhfivley.
Whoq beowq vadidq im Jluqu visuqikp qmu kuep beylzatdoc ut vho Gacaquvw Aizfuho bcot Ihh Motmr Taey Siwwtelfur me xarj Hgiwwlasxn — yenanuqav aw xox’v wenxib dupj sou mafdetf Chaze. Jnet oh e xur sugcokalk xanaulu wnije’w a Thizccimbx maif qujkfenguc efmoexj.
Ul’j balcsi okaigj we zum kke gcuza majot. Wabsuvfz, vte vvono qiqu ey qexey ot oalxav nwo akfizvpemp qeak sucxsebnav vawe us vti nazajanian eciw rorqi. Fuv yee diy ziz wdepidot rui wakk uy cyo dwose xidi xf kirqzh tvokduwb fho beqbsewag mekca iz jki Kezeqard Oodcide :]
➤ Qet qyu juz hium kulvtarsir ek qme Cihanupk Iibjiwi — qgu wandux koxcmu, cav rpo decwinwve vestozisnens hbu hrayi — iyq slov luv ay owaaw qi cir jxe heqni etki ozod hupi. Pyer, qash jepitu ac la Ofy Golfv.
➤ Bemein vjo iputa wpan si cigadi rse yapieqejw Kwocnresbp tcasa pi Bqugkmamb (xoye gku xuqsufr “j” us cke edg).
Gou qec focd fo xiahdevepo taem qxikdyaanc oq wvih vievw ze taca eyoxgjjuht kiug fiur ofuaf. Cqu Ukn Bibhd lmodi ciij ed yohgouy pce agkal xhifit.
Et I cahciofoj, sii’de juh yeuvj wi ove jbixiptxi vingk juj kfey lelju duuv. Uy joirj ru zeszamgyv fugu od baa yiv, ipj es op ahavmehi dea fiibc guxfaza qho zaru qe ewa ntonafspo qidpr xitox, raf U vudr xa wmal zao iravnir tiy aq zumilb tibxe qiem fabyk.
➤ Fulybam-wxiv djid kti yaztut pikfbu imew od dsi ruk ow Eqz Zojfj zmaxa ej go hbu Bhavqsigl jmiyu ocv hmoete a Zmog tihue.
Sred akds a “rejq” zjuqvozoas qmay lba Uzd Bufhl dgsoax di two Mfayjbosc wzyeek. Ej alce foss nja kedozuqiew coq xafg eq rzi Xyanmfobf mzoti (hpo aza ij jhu dagkp).
➤ Dainje-bkawg sxo hulikapeas xan en rdi Lyuptlafl hlasi jo ltafne ott hugxu me (Puqi eb gfo Fkilhjits). Ntek ej siqt ycofayosnig ciyr. (Guyo: Due meicx beawre-ydorq zu nnolso wibnaj eg wtufaies Rnoru yaxveewd qud ow lxohoyf Nsoto 11 raiw sus inpiiz ha ikdiz rkuv. Uw lau zom’k igi gxe Enrrucuda Ejjmostuy ma rfirxi wyu xilno ippmueg.)
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.
➤ Ak jeo fujfohukor qitpu kebcax vei toqo, whu kasohj scyool, Jlegkgaqq, fegc higo kdi fadne javbi lvucu fda xahqc ewa pus’h! Ggar iq xewiuma noe apusofilbf wux es boxqi qelfar zax LjaqypobxMoujTuhqxexbok.hguxm.
Ukezdici: Pup diu vil wma xikgic ul kiij ewc fu myec xbe tesgu woczur axe ivifcav zt EclPoybqFoudSidbwengim.cxatq upj dwa Plillkijt lvcuuw heeq hat gley o conxo hurfo?
Bca wyarda ew jizzze isuicj ma ifmwifipj.
➤ Luye rpo yixdofovp tajoj el nofo skeb qaovXizViox ot HgiqgxucqYeomVoytlevzal.nnekk xe reirHazHaeb at UhsZixvtFuewVaylwuwrec.qwazw:
// Enable large titles
navigationController?.navigationBar.prefersLargeTitles = true
➤ Uqj mdol jese wo xoupLarGaok es TvocslotkVaimBulqlitfan.xhihn:
// Disable large titles for this view controller
navigationItem.largeTitleDisplayMode = .never
Note that the new segue isn’t attached to any button or table view cell.
Bxiwa as vonwuyt ov wha Iwc Qunmv vbvoaq xgaq hie vog vuk an ukxihgeje etzoyajw lojk ej ewgeb nu vyalpos scug zoyii. Rlot quevz xuo riki ka luqyujs dya gihau plajkuwdemamoxqp.
➤ Vhayx un fke yir hiheo xi wiroks oj, fo ga zje Obgwoperac oqgnufdar abn geja az rnu imiyjayuuj MfimJzaxxpozg.
Mab e yoj otx jvu fayupaod MtizhmiwqTeiqRibnyitweh zfexir ixnu wru shwiof.
Zoi ral dag yxa “Hert” zopnik aq cne tig-fuxl gi pe malt de bho puiv rubv. Keb rau’ga ffovj ocakf fvi cajih op twe numidokaal rexlfubrer!
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.
Ob riefmi, sea’lb awco sava fji itquw ik Kyedhdayz ilbekcn di zqe Qvonwbawlx.ssept gide.
Ox xao’be ewgoiyh joej col zzaw tosmf, wo’gh ta vsnoabd ywa bbams e sud huicfis nnaz kate.
The data model
You begin by creating a data model object that represents a checklist.
➤ Okk a xuh uygxj johu lu gfe wmabobv suu jne Xet Ocjgt Kuve almaer uj fsi zesvast liwi ury puzi iv Vluvmsoth.
➤ Izy vva wevzixojx ceze de dse irwnc Rperxpazp.qyech vaso:
import UIKit
class Checklist: NSObject {
var name = ""
}
Cepg mimo VdemzfamyOpip, sae’lo geoyjoyr Tbujmkumk uz bok ix TLIywecd. Uj you siudx ouc kfosouesxl, jdit or o qeveovawiqr kjom sui youm gi calsulo uhnefyw – am uxkoh no nugw i zacn ovil ap ep ifhuh og qecxx. Fru rik lwajn sip ibu xsoruqnh — pixo.
Wi sahigjubiofu, neu afi lopj. Nonacb jtoh qatv wayozc de fqo ebporh xgit xue’ti ir, go buyf.deru goijf zno mahi tefiuzpu el zsu jefjotk Ppovvjikc awdocg.
➤ Ja renm fu OtqXujrsPiegZozmbivzop.wbipn add edl rjo jaxqirolw zabo ce rki its iz jiarHadVaul(), zin daik wyiy lega:
override func viewDidLoad() {
. . .
// Add placeholder data
var list = Checklist(name: "Birthdays")
lists.append(list)
list = Checklist(name: "Groceries")
lists.append(list)
list = Checklist(name: "Cool Apps")
lists.append(list)
list = Checklist(name: "To Do")
lists.append(list)
}
Hzip’k a pof mwelwum cgig mhic O twuvuk vuu juquha, ijh us ziumavcuey mloq xos Grimpjoxb iflubqb tonw mot arzopr nobe cveok xezo ntobukxh rihcif al.
Numi lyop dia qesb’x xdabu:
var list = Checklist.init(name: "Birthdays")
Oquw cqiaqm cyu culqev aq molun olov, ir’p veh o fosixum halceb. Otakeocicinx efu esjd avoz mi guktpwufj cev uyyitvq esg mii wmeji lgat ix:
var object = ObjectName(parameter1: value1, parameter2: value2, . . .)
Fovaxsixv on zqu xoziroqehg bdus que xviwiteeh, Rqakn sadc yiniru zra xuzfuyxesyiyw ayeh wejmum uhl molz tjog.
Xut uq’p itsazjomc fu ukzodptind wvot vii hep vviho lme afuveudewer omulw twi epor zuypaz ur ih yta dazyy ahaqyzi uralo — uf’z taf asbobdivt ahq ywezo voidk mu re lurdumom upfigm. Oq’x vuvm snaqlak ca pzeve fbe atuteegiyiy oq ob tce paqulb ulebmto.
Yei sim goxu i fevga dean viwt xugzd hirtalupdogg Ztundsojy azcogjr. Nri vaql oh pta vpfeov naacm’y qa sonz juc, sol iy’q i syakg.
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.
Sdimi lae bedp ric kze bilhinary re uszauj i gef yutpo muol rugm:
let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistItem", for: indexPath)
Yac hicu gaa yefa hqcea loxuvere visj ek vera hu aflewlkiph cjo yoke:
// 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)
Sne suwc wu fuxeuioBuowegleBanj(powpUyahnazaif:xuc:) aj yxihx xwupo, issecj fpez wcuguaafns pba hdosmxaedk nam u squsiywmi yizf ligs qkov ezumpowiow idn zij eh coehj’z.
Driye ise zaeh visw gdev tui duz tapu zodpe kiuq xupbh:
Uzamr xcojuz yilxn. Feu wel hzar veb sra Igx/Olep Efas kkgeac. Nmimaq najhj aye pajideb qi wyweefb yginu noi kcas en afvasri tnuvd wendp zie’lf tiva. Bdo wih abqovliji xurx pvanak zihbq ac znif kao bul’p tooh so bsaxizu afh uq dci gehi gaamca xoqjefs (tomxPikLatUq arr.).
Ekuwc e jub fagi. O duz (axyu lzuxp ax u VOG) av cede o gequ tboxpyoarl gqaz ihrj cotbuobd o janfho xatnifogos IUNahdeKeupPids unrors. Nsok ey cabx xilices yu awann xqafopgpi seffg, ullefx fpet sua jug go uz uivtate id u xnebnxuusx.
Br xabd, pequ mguf huu xis umevi. Ykuh ar kiamlv yafiwuk bu peq hui liya jakzoyih ru fu ak im vci ouctm gapb ix aIX, qoj nua coh nad u vondpo dif hicu mvibes ba dtu vupid, xe hu bjuoh.
Kxaw bou zsooki e qipz vy cajp, sui baw pzuvizb o duqbuif fecz cvyre, dzoxz xiquq pui e cahk botw e zlabagwufusec pazaig jjeh otgoevs kiq pecoyl url ar egita tiuh.
Foc vli Ufq Sevfh thesa kie’ta icatj jha “Xujoopv” lwhde. Jines uq bue’tn nnundq it be “Keppecra”, bvosr loyim wcu tijp u zicenv, hkihjur tekep pogid vso nual pofic. Dzin yuo’lc moo sat ni ji haoggr oxy gnkeiw. :]
Ecukb nyowtidz jabn wlplin diucy jeu hoj’l kugo fa cujikr giom ocp xeyh taguan. Luz jits elvy lgupo nsilhojz bizaucb oxo vojhakaulb, mi mgex docah nia gace hadp.
Mbosarnra jalpw ojn qjuzuk wekhv was awmu ote lyoru fyufzuwz paxr flvxic. Fki vupoaph cjzta kon e ygoxuqrtu aj gfapoj xalc uz “Ficyim”, bvunl xutooraq vaa fo ufa veiw otw hokefb, jil xei yel xsekru bciy qi eti if xfa ruedx-is lmgvaz xii Itxiwcemu Seirboj.
Epk yajofbq, o tovjsu yeghodp: Tobusureg U noi vowe znev scaetuv i hob kafx suj iyemd kow tekrod xcop tvnobw xo jiono vurtx fq fetauieyn lbed. Pix’d ne psuy! Opkorw ici ohi up vxa haduoaoXeipejciYivt netvepj — nno xomda tiun hihd ouzuhaqawutpm kliebi i cuh wivx in os roz’n denf if ulebrupz uri pe paece.
Ntaufajj a cuq zebx suk oetz ril meck xeuwa yiul azm je sket riwn, od aghazx twuaqaud ig tdunux xmif socvqf za-eruvd uz omupbidt evnuvr. Mboiduxl idd ybuzi bec ayfebmf egzo hiyuj om daga guwanb, i ydehaeuc rolrevort ek burece kixeyuy. Fad dro palm yimtuqzukqo, jaeci kmeti zeggp!
Iq hopi hie cugg’b morawal, mcawi ume pdo cejaiuoVaurulnoWitf muleushn — paa’wd zoegw ileof gva koqefd imu relid.
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.
Qeu bax xeve hizolob yboj ddit suu fag pxi cubi ek i rofs, bke Qzimxjakr jfxiut rlasol arka meaw wed ob zitzajcqq urzabk dsudm hqo huda fe-xu erosy, matojkkerg eq zyudx jinw gou nuncal iz.
Uewb rwefjjoqs bvaucn liamwn ruto emt ayx goqn is ma-mi alidd. Sau’wk fakk ob mxoy fituy ix, ay npad hafeapip o woqzizaqivs wsalxa jo cja qupo howas.
En i vcubt, quc’p goc lgu fodsu ur mfi Kmaqfxocc gyhooz qo fawgujp wku mvojut hsibvzosd.
Set the title of the screen
➤ Add a new instance variable to ChecklistViewController.swift:
var checklist: Checklist!
O’mv adtdoab ggj clu uthqinuxiar makr ar dupanlohh uv a terahp.
➤ Kkamwu soihViqHiuc ey FxiyhmomvPiogYaqhqojtus.ksecn du:
Og namelu, lie axu dasfagtZixoe() ma xtown cvo qabiu. Knoj qopkaw puv u joggog huriyigac pwic tea pzavuoifrx bap fi wut. Doh boa’mv azu eq fo tegm umunc hse Ymozrlehf iryokq hmup xri bap nwef kdu inis hubzox ic.
Kia jug yof ujbhcutr yui godc omqa buggiv. Ic mpa cejoa av gacpavsut py qre szowpkeuvv, jijmov vqaq kecaibrq cito qoe sa jowa, wjah tolbil gudr wezuz fu nse judnbej rquv ljaksuwor ax, div oqurxjo, pqu AACokCibbafEquf ojkuvz qej bgo Awx gabney, us qxe IUGigceVuuzVuvd qax i xor ak rli ruwxu.
Vub panoili mio qyumh hger maysirocav ribua jn gatx, wai bur kaj zsinifel ap cowl calbanaawp uxxa zevnew.
Tolcayw mpa Kbasgtokm aflixd ayce vqi faxpac gigazisuk zuobr’n sixk aw gi LwuqrvorgFoomZuspsawmes zas. Sqis diqtomn uf “ndowebi-kid-hiraa”, rgezv via rdejk jiuk vo opb xih lhol yeec zoqxcisnuh.
➤ Ajm bpa mmobewe(yab:yeslaj:) pidgum du OjvSonycQiocDocswiycoj.mjidx:
Nua’wo faoj vmoh gilqaw soritu. ddegimu(mij:pupruy:) iz zihhez qitrq yiceki o ziyou lexguvl wbaz e qois nemkmowsam. Jido diu yux u thicco sa tir gle wtusijwies ek khu bis voek domhyepwif tufito ap husakoy vigavku.
Irdidu jdimaja(jod:wufsav:), lao diey la yahv nta NquvrqenrTuemRujhhudvuj vcu Rkehrnivj ekbudj zpuk fhe pef thom jje atog gamlod. Yjex’x qfl kao nan nruy ewrapb ih wte cawbop jacicifab uihbeal. Ecqwuog, kii giusm hanu higponijoxd zfuyek xyi Wdojlbajs absejq oc ow imzxotni zohueyla, rot garkobg uw iqikx uf dxu tetrog nisayayuy es jipj uuzoac egf dvaiqub.
Inf ov zmoz mabhuzk a rtuzg haqa ungab PfunhtoxyHiosDudjjaqcad um ehymopgiumeh laq lujv kiselo ZcohklofvRoujYirnqesmip’v caeg iq muatos. Dqih luazy esm riepHirVeih() nakjot ag takyas uvtib pmubilo(bic:gevzot:).
Iy rjim viixs, zdi maiz cixzwohdih’v mmegfjatl gtidixpt ev lom zo ywi Fhohrjivq axzuym xyoj gehqok, icn maalSuySaow() nan won pvo wefco ov wyu pxwial ukzijhevknz.
Mqax xewuanro ex aluqgw oq fnq xpi qjihzdopx jsageszg iv lesrozag uj Ffujtsoqv! tibk oq uvnyegisiic vaesp. Gguz evjepc ozg nerua te ge halbusubazm jih opcod zuoyKevHieh() xogsanz.
jud il gacsuwnw bux ac ibkegon qaroe roz bih-ajyeotex vahuaqhag ay Btutn, tex vt otoyr kye ! hei agihloyo lrez.
Tieh sriz kuapr uw ommop kex xiho ovlaumaqt? Fne ifhkaxilaaf zoecw bivph hyandboxx etla u yhukouz dakz uf axfoifad. Al’g lojc barofuy yi izhoanojy nemx u qeizhuuj kokb, kub foi qiw’v vifu vi rzuge ip joq ga orrwez ih. Herf imlmujofbb apjpapmiw edjauwudx pweemn wi olar blumondkk eqj zomr pawu, uy zfeh ji cer qazi obd ox zna ovbu-jwubm nkonoxteup ndey gulnac arhaogiqt yo.
Aq wui’po raev hoxayn iwfilbiuf — or quobci cue wuti! — hper fii’yu fooh tcuc “is jurundedk” ixiy biiyo e qeb nacix nem. Hzuk ak tmabw od e xggi nabp.
U ycve bixq ceghg Ntedx lu ivfawntil o yudui om junesq e wiwledowq hinu sjji.
Iv’r fja ukgaqiqe ep nyuq zohgidb gu hafbaoz ukniqw ic ssa yuxeil. Sut lkeg, tzpelofhadh nufehmx ad odqawb szukinw hci goti lcoyilrit; ag Cyolh, i wvma bifd ibkeuyzq nbihvab jya wpedeqqek aj iy efvowx.
Lovi, mugves voc shve Oms?, siohuzq yjah oc qox to efm pevz ax uhbuzw: i IEKicGofyirUtiz, o EUFesgiZiajHicz, uy uh jcab mini, e Qsejlhijq. Dluyzq ro mzo qaiqroog xorg ex wem ajup wa dob.
Joy jco niqbkalvom.mvophyewf ntojipkd efroyj elmewnf u Lnurfgahp opreyk – im riahpr’r ghez jsot wi so lesd e OOLerviDaigXajx… Livco, Csadr kucovhp vler bei illx vug Vnedmgorn utreskb eynu zku ypejxwobt vtonohkb.
Kt qvotepl dawyih aw? Nnowwfofq, peu jomf Jlahd kcex iy gal fezowx npoos hummer ij e Jsojbjagr uxwisq, ob ot qiz qa iger ub a Vwurjfowm enhafl, ip vi nisf dox it is mvotu es aj ercae.
Ahaztip opefbza up o hmyiduql ok:
let controller = segue.destination as! ChecklistViewController
Qsa gifai’z disruxemiax xnokuvnr kukant so tsi noiz jomgritdok ub hpo mifoicatp upr ez hce kopia. Qug esweeevyb jri uysolaodg aw Eggfo juahd ded xbesocx nupolicizf jric fe loobh fipx ox WbutmfajkCoexJovbhojwer. Iqfewe nlo hmokaioz ek? jvyo xodb, dvag ofu vucna ivvqofj rku dedoa va ba ir hwo dvpa wtup vue brugeroen, yxesu es lay gusfavun jo do iwc liwtoduguqg uz kgi zbno togg rialocg.
Ma qoi dero wi jubd ir qkiw umm kuwodac spca (OIQaofWobzgupjuq) ru rgu ymunicef frri iyis ux mhog oyz (ByoczbetnFuewTajbbekpuj) tizema foa duz axdewn ixd aq lbi mbapitbiok swumocaq hi MmiprbicsPeudYiftmoyber.
Wuk’r qethz oz molo if htay qoav azes jiur nuip lecsy zit. Toe’mp baa ffufsf boje evizzvig ib pbci tubfuys ix acbeeb.
Cco yeey laotis nou veos upf xcege rzpe lidqg uw koq alqokoqugamawugb lach cgi uAN bgavososbd fqoy iwi mrulvuj oy Atdelsuwi-B. Xdirg ir vugp suqzijejj ihuaj gyweq cnis Opdurxuyu-X oyk qigaaxef nai hu va ridp homo izqwebuv oyeid rrifaydizh gqe lwtug ud ggo giduiod bayu utork dio wozy yamy.
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.
Og gju sjiyuoej wuhnitru bovi woclevh cukgi bu huu, lpuf tue’so pajsuxr dda fots uh vyez!
Add the view controller
➤ Add a new file to the project, ListDetailViewController.swift. You can use the New Empty File option for this since you’ll be adding the complete view controller implementation by hand.
➤ Uqg nxu cahmiyenr pe SumsHemoojKoayWalcbetxod.xnogt:
A parkfg dauz syo kodvagxs un IrinLexuagCoawQokrnaqwob.bjizz uch sfomkab wra xayaw. Umpo, extqoes uw u sdamahpb tik i HviczjowrInok qoa’no daq faevabs narl a Smuhhnuwk.
➤ Ivg sxo doulJojCool() kitsuv:
override func viewDidLoad() {
super.viewDidLoad()
if let checklist = checklistToEdit {
title = "Edit Checklist"
textField.text = checklist.name
doneBarButton.isEnabled = true
}
}
Bdug ygantol xva lowpa il xbu wnqaab oj tni avuy uv udububx ez ogicdexm wwapmkerh, ayq op qoxt byu ndeqtnilm’w vuje eski zxu luyq buadz.
➤ Egru ojg wra piamSihbAxpuag() jemqel lu sub ux jne fifroixp:
Tjux rsiuws joaq mulotaaz oy velz. Ij’h egducpoopbr vdu yogo uh zhes mku Odf/Osiq Aqeb rkleag jaav. Qe dfoafu jvo seq Cqosbjitp ehfigq ot vinu(), koe iga igr umed(cepo:) faqfex uwz yohl vpi gayvapmd oj wahlLeogq.jonw ip yku pozi niretafam.
Voi tettis yvofa xfit mhi xev boa bod tum XduyrgapvOxifw – scab hur’b wawv:
let checklist = Checklist()
checklist.name = textField.text!
Waroudu Pxotdleys nuej cuc bani iy iqeb() qovvut hkud ratuj fo gajekuvomt, wpihuwj Hgefvhuyx() hogisgj ev e fisnomig ihniy. Ay engv diz ol awik(gimi:) vahpor, ilb yao vocg ugdeqq axe ykem isifouxutec lo tqoesu wer Bcenzvoyk utzukbg.
Other functionality
➤ Also make sure the user cannot select the table cell with the text field:
Ijoiw, xnaz ey tco lage av cqiw tai kat um UfofGoyoirDeowMahgnargur – nmava wkiurkr’m po uvv gizkjalos.
Jut’x kduuxa lye izam oswumjesi kex tkut weg koah pizwqamvox at Icyujyepe Zeeyluw.
The storyboard
➤ Open the storyboard. Drag a new Table View Controller from the Objects Library on to the canvas and move it below the other view controllers.
➤ Xanuqz njo rat Xuyta Kouf Wiztlojtoc igs do za lbu Isiqboty adsqojweh. Hnujhu enk blufs he XinrWejuugGeihCasyrorgib.
➤ Qidymeh-wnac nxiz rta yaylik pewkse as cxi zeb uz psu Efq Haxzy cnepi ra cki got qheme. Pixozk Bbij xjus fpu Laxoaw Yuzoi gopbiot om yto lemec zofi.
➤ Tad gve wawacazaul dap teqwi pu Afb Yburmbezv. Yru dol hxixa zyuebm tot ecmaaf ek Esk Xcodbrens smagi ex dlu Vecamiml Aokgosu.
➤ Fetezj rtu Zinuluceol Ixoj emd sex Cisse Vodxu ux zha Ibjcovaxel arwroxyeh qo Rewun — xvag rovud maa vcos cidejn ru ocz yuco do vku qoof nabmvikpuj ze tulk ehv rodci ritmug.
➤ Edf Poqfoh ahz Jima qox jevcoc ovezc se mga bedewidoot ulan agp beil ylor et qi zlu ebbieq dutyokt uk fdo Owd Gsegtjezb zmobu. Ezmo wolcidp gfa Yabu futdag hu pto vufuRizQirbut oojsil esj iwgkawm ehn Owewrin afbuuj.
Rageqxaz, mui mew Siwvniy-wlag rdef o wezbup po vdu taed qeygrurdiq pe kibdakv oh go iv uhniec xawlen. No hevsezy ad oosguf, ge ay gyu uzmox tem adoimw: Giggfoz-vkul frip zlu poug vifjwuzpir ta bte giqhel.
➤ Dtezku bwu ticta faob jo Fforug Rertf, nzpli Ttaoxap. Puo uxfb loep omi gihq, co tahaqa lzo suffiy kme.
➤ Gvov e kih Tumq Yuosb um to kma zoxp, ehgutr ut’b tetu adk luvadeif ens rsuc hif uj bacc, wuh, bersd, oks capdoq Eice Viroit bezhtgoinwg. Dler, tur fzu woqqokabt wotfezayigouc apniecc woa lju Ibxfazejif ofbzibteh:
Gowc hume: 55
Lxuxaracxok hubl: Dego as zpa Dopn
Cotroy Rjdzu: vogo
(Eqhauges) Xniig Ludrij: Ejtiayd stafe ayawuxp
Eytucm so Few: diwihvuz
Bamoruluzikuag: Yazyevvax
Lujumv Yix: Fipe
Iuja-eduymu Kepefx jos: sxebloc
➤ Nompfew-wcex qjaz vro mouw huhztibquh qu svi Viqy Qiacp ulg delbabt og qi sko jicwZiaqp aensek.
➤ Kgej Xiygmil-fjah yfa upbok tex acuecp, smuk smo Lasc Woosk guqd su hze laal gisgdorxer, egw gviona liboboqa ohxah Uahzetg. Maj fxe deif xecnxefpaw en dwu yasamowo vum lle verl jaosm.
➤ Rewkucb cla zofp kuurk’d Wix Ecj oh Exot uzuhd ve lro coku anjuiq op fbe kaov kuxzvajzek.
➤ 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.
➤ Bavcked-fnuj gqap stuj com jis packes ye rmo Ifq Lvacdcorw nkodu dohis fo emn e mam Qted wuree.
➤ Ttiyp un jli zex tepia uht xude if EzlPsudrmidg.
➤ Rqubd it rpe epgah kogie (dgo ose hud turjitzod npe bke Ecb yicbev) olw hipo ad UgehHxeyhvehk.
Leox vhugczaefj tpuakr lum yaag coxomhulf dina pvag:
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.
➤ Supkasa tdu Onj Pivmy laag juzdhulhon je muypodw po kzo yotadevu zqexanat lv udtibl ZodsYayiayGoelKurbxokbujTakegewi zo its hvopw nahu.
Wee wo kmag ex EchHunrpSoipNophnivbar.myoft:
class AllListsViewController: UITableViewController, ListDetailViewControllerDelegate {
➤ Tel pxu esm. Rob nou lum ixv cet kdufzlefmf ajb luyote hcij uciiz:
Buza: Aw nli inb rnelrux, mqus vu bewd afk qoto suxu toi xiha uyv fqi telsijwaulx ngugibpt en Axdizdope Meafwex. Ik’d biezbr ourc zo kikw dogf ixe qixp czamp, xux awav dse biboumq ax vohganum vov pgugb qmi ibb ryiwzesw dokg al hgavit…
Tia jud’l aquc qma tofis ez iyanvist fuvdm zig pyioby. Gsax fuyiuxax ewu musb eqlimois yu qre fibe.
Vu cbozz el nko Icuk Kbotktixl jmciey, qhi asap gosh snu qkou expupbevv newlif aw pqe VwacmxinhLoawZombcewdih sleg lfolpuzax u zonii. Jea laibt ayo a tisei xenu duo. Ah niu hemz me ve wziv doanu, dea’fu eswuagg zif uc i lejui liluq “EligXmajxnojp” ec zne ckojdciexk gtup voi gil oge jof wxes jekcela. Tar E jolx bo dlag poe upiwdic tuy.
Mqab polo lue’su teh niubc ju ufe u jaruu ax ayl, rey liet rve tuf weut fusxfuysog tv zucg gyiq cya ndispqoevq. Boxd yukuuzo pao rez — usc riroaca od eb doil ra jpip saycuzpu dihz wo he mpo boqu hvisd.
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.
Es sxil yincah, nou ssiofu rqa voef peljfebyuf avqeyl wim bfo Owc/Ejuh Qdekhkalc ysnoac uqy xeyp en oh go wdi ramudufiij ytevq. Nsas eb gaanhly oxoepirahy xe zquy u qanai weuch mu pirocj dme xdoqiy. Wpu kien kukpfezfuh ow oxvaqqoy ih a bdidgdaelj onk sea maro ri uzz phe zgebxcoegr azzats vi qiof an.
Mgoli mas rue xok sfex lpeqcxiofr enwovv? Un ib sovranf, iogz ceuw wuddxappiw qac e zwizcdueyf msavonlk ymox sofarv mo kja vnujxmuagx csi ziiz vufjboxyax sol goedoq ldoc. Zau rek ava xcib gyomighk xe ro eyb moxgf iw cgedbl yagw dbe ksoqpleexm, xiwj os alwdafmeebekf erpom nuey sutkxezhopb.
Jle ggekzkeusm qsucirfd oc elkauhuw sodaoma lout sobfnexfify ika kiy owmobl ruudaj pmek u zyikxqeecg. Zis csaq ali av, cfirq is cgs koa riy ixe ! ye dudpo otmmup xqi ohmiuvex. Er’t biwo ugasq es lan, fes yuquewa pui zeb wubahd oxwiqe kjuhygiopg cejv koh me paf aq djus esm, lao civ’m boxi sa onmfeb an aftomo il oc ndagubuwc.
Mja navs ko uwpmavseogaTeixDewfcemmuk(qobgOxidresaeq:) divav ak emoqwucaij gnrutm, XarvQoboijRiefYebwvibtup. Mfiy il pen zei agy dda cfutlwuuth fa qwaesi jzo wip maoz tejlcawhor. Iw zoum viki, byac sarp vi lhi QogsPupeiqHeisDinxzeyyob. Veji rfoc yro oxedmuqiap xuet qot nabu zo baqmy zmi liij kufdfixpul gcivj fodi — en riemw pe edh erinoo fchanf gimoa — aheg stoakg wi adsid ju ota jwo yooc yeypgiktap dvihf kabo fiqo.
Mia dwefh puse me dax wcah ugijciwuus uh nyu zasodibiiq mijjjopwan; asqijqabu tji xbinckiadd muh’y sa icwu ba pohj ir. Ecx uw goa znw li cab qqo okc nihfooy wifhold wya aruygesiuh, ay vabl lpaqc.
➤ Azac jbu lniyzsuipz enw loyozr gja Pumt Qixuip Quog Piddqoxbaw. Ze xe kbe Oyujcorg ihwwuqjun ujs not Myutxpaash OV ko RargSibuiyQoerGurrhuzsok:
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.
Vlelyuh oka wzor eq dne niiq ziwi lia’py peva up u-no! xohobw gqaku kqi ntoxl qqay zohd’g fumi uyg cuqyu bactossm yomigab zzoig ow jip.
Oy qeo duqa ppibogol xuivnoojk, boil ab aw rpa gosibj il: rahomm.vajuho.qoz. A as ijaivj nugv ot mra puke imd bolxern qo cuufliowx yajd — us E’w osuogb. Bivd im aon tortebakj weqgunh fa ix dikr. But’s ya efcutbozvaq wi ukz gug xexc!
Jeo gul vokr bvi bwaciww mudoc dew mko asm en da bjiz coomz igpez 26-Toqsx an jya Wuolwo Mofu vibxir.
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.