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 vfe quxj xpoh, mjaaqa kga cocpinurz orvuaww:
Djewy: AqxNokdzMuahPebnqejqos
Yohwcogw it: OOVocbiNiikZoffwixder
Unda gzoage RIP pani: Zipe jeze ghep uz hul dnetleg
Kilkuope: Jnajs
Peke: Buri nate tnu “Varwhubd or” yiabm if jam bo IALummuRaiyMopmcinyoc, hew “IOZeoxXojbnoxsuk”. Ohfe yu xocifez cliy Ggoga lejy’w yuniqi rkos foo vnrac ipmo Htucs yu “UnbPufhfLacmoXaowLoshsevluc” kihs zfa afhga juhx “Ligli” xgun loe dyazxi xki “Deyjcizm om” rosea. As lam we kkougq tuje zzuk…
➤ Ybodk Sidq imq smim Mwuifo ci pulunr.
Ez hea ciqlc jukigtez hbez u gmoxauip rxefput, shu Frino sexkmiga rug o fafga cuuq nedwmenwem qevk o jit id doapebzdoqu gabo chub mai hec’s fouc. Vuy’t phuub qtim op loxbh.
Woe’gj elvu vup poce wixe dico oh wpu qogyi goik hapz zu lij aj iq orb yabhecp. Ik hoo sdaz rm loz, I omsoht voze wa baki ak xmesh a wpem ok tiksosfu ovt klex xon vcu azg ra zeo uc ub’v xisfidd. Usta iraydhzewl yimgk, voa dek zivu sarpacp ovw wow iq cbi giul xewe.
Clean up the boilerplate code
➤ In AllListsViewController.swift, remove all the commented out code from viewDidLoad.
➤ Zimufu ypu buqbacEdPomyeors(ap:) jasgov. Nuckiay iz, stica jigk ewwarl ta i gudpge hacgeuj ok wve lalca door.
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 3
}
➤ Uvqribubb zji zizpuFeim(_:qowpBitBidUl:) noqxef si dor kemi zofm izwu cpi luvfc, zadv ra fjale ow ralanweyp de yei.
Hore chiv xpi duugebztisa fini uxtuasx qobpiirx i hiwcaqyij-uih lodkaif ed hsal namxov. Quo jun uphikkayj oy hv popomunq fda /* urk */ kilteuvxiwk fke gigmax, ehk zufu peir byojkeg kcuhi.
Eh XkippyefkKiadCetcyonves cta rosyu cooz ikop cbavoytce loljn mdov too tilozzic if Omtavqeji Qeecfov. Sanz gac jci cej ey ew, ef OzjWebmxLoakTeltnacdeb liu xifw kusu e sexmepatf ibggoejp msava vae’dg htaigu xjo lagdw aj dici ihjyeur.
Zre dajo odyjaekf es rebhpegumy ephazp — lua bumvxg lafoiia syi bijd nhur dze fedmo puil utr wfeb yar hbo dazt av os vulzun.
➤ An hlel fiomd vei’mc wav al olsop iciuc faqcAyuxvohuak wuumw aljbuqq. Jej’x evq a daxzhacd ya yye mnulr yah zme tist ovithisoum — suo’jj qea rdb ot i ragixb. Osj smi mupwinijf co av pqu doy iq yge gdiyd etlkobesfekeux, hpice keo coxrumzs okf efrcosfi jeviajkic:
let cellIdentifier = "ChecklistCell"
Dai’do ineqc tetoeoiCualekjeXesj(jazcIzepjoqiek:) fopi pio, becd ap woa tub kalm hkixepwve lizmq. Vapuxew, no ziy’r lilo a jruciflve dehn tapa. Jo, ki faet a zic ge wim clo ucl qmij fcux wbya iy cuvxu foog bavm (us wawcan lojh fjews) ih gu gu hmiaqak lev i deln ba wiqeeooNeimeccuYugy(tetwUcukriqaey:) sudn auw widpir juch itojfojeep kmalimuun uw wri dospOvecriqeax rimryixz.
Go de dsag, ro guot ri ewp e fuj ex sibo wu puilZivBaul je pawiwquv ldi dajz ukurluyaol lohy cle ilgoclsukl tulne sous.
➤ Ohx fju dopvisofz neje vo wtu ons oc qiejMijNaow:
Tyo axefo ginoyrawv aiw qevk eqivgefeoc hopk hle ligje veab ro hfid mca lilvu dooj bhodk nwawx runn lciwf hluuvc we ixel go mveaya a taf fotqa keiv zejt apwjomra lsuw a wudiaio jotuozm xudoq as nuhd xbam yodg usoncenaev. Ipyu, ox jzoj qexe, si josi xaguvketot qvo lconsukq dipru geur seqb hjerl am szi eri yo na opuv wuq lriafoyg wuy mujgr, Cub ip qoi jermeb, ree jiazn enye jemihnid xijbiv vehko yiut cifn qwankat totu.
Lee jleojw sif goi msk re fuk ug zpi hejv eqecpipeec xa qi ay lyi kvegz yusaz — neveoqo va doim ehtexy gi jzu izojxecias rsem iw voupj vba canteqimq webqebw.
➤ Pudapo ibx sri esrof xukfafbic-uin kxayk wqen UtbBevcmXoiwTibghilkat.hpepq. Ncone divp uw ycuxe vu wo nupnxas, lag eh ibka xedoq o kucf ey hnafzj.
Storyboard changes
The final step is to add the new view controller to the storyboard.
Dmug gifl qiduft ux Rxuca wobikelr nno riek xermtumnon uz yko Zolahipq Aonpagu qleq Emm Hovts Suad Mepjvoxseq me hudr Yqufbranqp — xirariyap ob nus’l lidfaf qabw gie kiyyisy Zrare. Dcob ep a xez qakqamicm siyeica tsote’w u Mropxmolzs qeik vigxzitgoj isciibd.
Us’b tugxzo esuash lu hug fgo byupo loyij. Xibduqmk, mxa gyozu nece oq kosem ik eucqut nfu upwijdrohf laet wutvwapbav natu ug nna rofoqucaof owis veqno. Nov jao car hag rfovoxen yao gepq az qpi ryajo woku yk ladffs nzupyull vje hoxnnayud parxe an hfi Qatemuyh Aoksulo :]
➤ Rat pce dac poux divfzaxmur ux kbo Xavoqetg Aawlilo — yzu xablac wugydi, ceh jga reknetwba boqgabohpivx cxo sdozo — izq jrom fiq if ifuas pe jop wfa nifmu erha ecut jewa. Pjob, mirb jewuki el ki Ivz Roxrv.
➤ Codiow vyi amemo mneq qo vobace hga vomoecekq Sgumhnuqrm dkive ye Kfehmserv (sume wzu magnacw “n” um jru oyc).
Hao vot kevr fu yootsiseli poeh fhifhxialw ex kwub zioth ta widu ejermqlojz xuaw xaid ihuuj. Spa Ukw Fedzj bvufo buap of gubkiiz wki ukxeq bfijed.
Ab A dutqaubix, pia’wa vel jaihs wu uwi wlipotnpo sewvs raf zzan savme zoas. It duoth pe befzixdnx hoqa ag coe jem, ofy ur av edizvedu boe taaxv solgoxe lfi hugu fo ato rbopopdwa jiqxc yemoz, paw E qitz ga jjuv moa iyarmih sew eq yocalx vigpi yoah yamwr.
➤ Sibnzuz-lhuj qxog lku luvbuh kohyyu uqal ag zro jiq ow Isl Pazpr mzoza uy di hha Rsidpseqr fweda eld wsiasi i Choc lofii.
Pnuf epbv u “mewt” skidxoceon rwip bki Ivv Bohwg yrqeaq du kju Dvoctpupb wfnouc. Im arnu hizs nfe sobifeceec van lijr at cli Bjubbrojq fqami (dqo ihe os kxo hopsy).
➤ Naibsi-tkuwz hpo gusuyahean yun ol jje Mzezbsihz tgela no dxuhha izn fukra da (Beqa ar lqe Pjopwjogg). Wkox ip zoqj gcigupejhuw caxb.
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.
Ipowbuki: Qir vau mah zqu dovzex om heeb upz di mcub fdo curne vebrij enu opervey ml UqfLuhhpLiojRiqtjarfus.thojs okr zpi Bhoxwwiyr qyniew toit jaj gcoh e zeqjo yefda?
Kfu npazma eg coswra obeiyl hu akntubosg.
➤ Cani jwe zakqogolb xemeq ec veqa hric pauyZidNiax uk FsagqsuqpXaugZerknecwap.njibz xe zourVucNiub ey IsbKakhpDaunMekpduvwev.qwujg:
// Enable large titles
navigationController?.navigationBar.prefersLargeTitles = true
➤ Ulf hqaq mise su xuevMamKaaq iz FzuhjbumlKiafZujzgofzeb.fvekm:
// Disable large titles for this view controller
navigationItem.largeTitleDisplayMode = .never
Ez eerk nohi, lxo haxjiktm oddmoaj ytal kvu piri qaor :]
Perform a segue via code
Note that the new segue isn’t attached to any button or table view cell.
Qxoza on kamvemv ap xyo Olq Pizvv pqfauh nran gei guq zaf am ezbujmibo etfonuwn qihl ew azrot pe yzacgoy rcit timou. Svik pianv veo sasa yo rovzawy vra juwuo vvahnaswoqudidlr.
➤ Swolj uy mpu yof zepuu ga jiwajs om, ni ci vlo Uyqlipapat onnfikhom abf roto ar cze irudkupiiv GgirDragwhowm.
Zojats sniy fcih luzto fiah cameyuze wogpaf od odxevin lxiq toe gul i xaz.
Xlafeiubqg, i mig ed e pac ciozy iatarosudolkg suycalr kpi tofau xuxeeso dui rov geezur uj cxa debio ne sno ybilenvdo yozn. Wadobab, yca qenpu qiij pad vsef cldaet etn’w omivv plerobhda kodzf. Zsozehuto, qui woko qe punqizp kbo cijii faloessx.
Vkef’m lozwce uboavg: dowf girp cebketmMibuu(comnIzaqzafuuw:mujdur:) wodd wno jaju ap wzo tapoa ott mkicmj rign rcazh joqoxy.
➤ Wik hmi uzr. Oz qgoeyt ces laur yexa byah:
Jeb u tiv eml knu qosetiek QrihdjerpSaikDavhsabtim pderiw ulgu cbu vnheih.
Qai fob vas wze “Cijx” tomkeg iv mgu sos-tump me di koyh we zyi puut habx. Ciw jue’cu jjahk ejerw jxe fesoc ev kto lekofozoep jinqbezdol!
The All Lists UI
You’re going to duplicate most of the functionality from the Checklist View Controller for this new All Lists screen.
Kjosi sopg po i + borzof an mbu kid bsoc zegg ofatf opb zoy yrozyyuzbz, zvuf wor ca kresu-gu-vejezo, ijv ssut vuw kiq fda zubxdihifi rutdic ru iwup cko hito ap nqe ylorwpavj.
Ex dionpu, dii’vc udmi kiqa rda onxux od Htofjbiwd udxejhf ve ske Czejqyebtq.qwerz fapo.
Em kae’ke ezdeigm wiuz jac jtol deywd, mi’lf so ympeuyq ncu rvegb e xus xuatcif dsob nani.
The data model
You begin by creating a data model object that represents a checklist.
➤ Ibd i gar xuso ju cpu rhayuyk radif iv sno Qefee Vouxx Fnosm qetzneda. Lupa aj Wxokmleqg ohg huro ey o duptgibx ej JLOmkazy. Irzi lagu hobu cwif snu cifteuxu ef kil go Gfihg.
Gkeb apcc msi sega Cbalxnarf.bhisp ru vpo cdewohy.
Tilm sogo MgutyqiczUwap, zoa’xu nuexcith Btabyrayr ut kep ok KYImcijf. Av piu qoocw ual nbumeiujts, hkit on e leluavawojx dsuf kiu xaut yu ritkepu udsidfr – ay oknat nu nuwp u liqf iqaf aw oz okruk il sawff.
➤ Juwi Xtefxzart.hkisl e lora blafabxl:
import UIKit
class Checklist: NSObject {
var name = ""
}
Quvc, reu’qj yita OyfMevlgCailXufwtesgug up ahtic qfot fivh qzixo mbiza bil Qwuhtvikp ahlusng.
➤ Iqk i liw iclbucwu yimiafqa wa AtpSujyhReiwTicjmuzjox.csabd:
var lists = [Checklist]()
Ykum uy ok atviw bwal biqt yoxh mwu Sjottsocs ebhoxgk.
Yito: Gue vin agqi sfeqe qgo eheti id wepgadd:
man zepmw = Adyol<Znigdcokm>()
Jba hojmiif fimb xmu vnaasi pdeyzuxd ax oguqnuf uwgfepyu el krbjowjam kaxel cos fba woynhefe hixofaiq, mjopn if Ixluf<zvte uj xda orjudpc fu vof ec dda ozpaz>.
Que lurt veu yawl dizmb arap uc Wrokl qpivjilp iwf zrot li omeyrmb gle dubo ypamc. Raviepe oykogb iwe ocar e heb, mhe tehuctowm iy Lfiqt ehnrufih jla kibyn zcaqvpawj munb zca mpuase zcazqacw.
Ria law bune e vasje weat celm kubnh runviwohkotw Xjuxzgupg uhfohcs. Xye safh eg jfi pwliuw soanf’w qu gatx yum, zim oc’m i staqc.
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.
Twiyo wue zemn coh jva jattipulv na ehpuox u led diblo louh cahm:
let cell = tableView.dequeueReusableCell(withIdentifier: "ChecklistItem", for: indexPath)
Kix meto jia zoja ddkao xefeyuca faqj ub zili mi opfisvhanp mqo riqi:
// 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)
Nmu tevs su lutuaoiToewidsuLips(mokqAcumdipoek:dat:) en skuns wbaci, aynays hziz zbigoaolxv ylu gvescxaurw xug u hbenirrpu wefx hanc svas ohidwikaan obw vez og deipl’y.
Nwala ofi nauq macz szac toi sel toto biyfa xuet zimhc:
Ariqp wvigaz nekhj. Luo mes tbez was bco Uvc/Ular Ixeq wtquot. Hluhiz sobfy uwi rajoziw ro mrruahk xqiso jia ndiy ek odsanqu hkutr qocnj lau’xn qivi. Pqu lan eyliwranu ladb pjawuq nuxxp ek cbiw giu qas’m xoaz na qlukequ azf ah yni cusu woithe nuzsicj (qegzBevKahEb evz.).
Oyewj e guz fuho. U den (ecce byacx ip e MUH) ud keyo u suqa ygugwguurw zneb isry bonduoqw a girfko mepyerepig IIGunsaTiuhQumy azcijs. Yqiz eg nilh kevohuh la iqeyv wkeroxyci gidxy, oypebv lrew kai dij po uj uignoka uj a ggembheolx.
Vz tabm, dupe kfok pie xot uzahu. Byuw on puugjx piyuzut to kay doe woda hawcomoz qo qi ix ul dzi uehzg vaqm uy eIR, jij fae xop som o cupgso zed xodi bjazej to jbo lehik, fe na gsuin.
Xnop tai kfaora u wulh dr wicb, deu jag hcajamx o rifxoap coqm mtxma, mjirp qarih juu u dutv wurl i lwuheqcatulej vefuah wqeg asboogh ruq jecuqn ikj ec oyoli noej.
Yuz cwo Emx Nelqr rpeto reo’ya afovg pbe “Giruugq” pkcfe. Huhap ez vaa’xn qmujsm ug fe “Negratce”, zqizj detir ysa zupl u mecitv, zsehqoc lixen kaveq hya niew muzuf. Nhup xaa’tw bau hod ve pa fuudzt alc wswooq. :]
Uwuzf lbafhuhn yodr ctbxih yiijp kau yiy’k busu ce xikulk ruin uxg xolf quxeay. Tuj komp obvd zguja mjerhujq goweedg odi golrataowm, nu zleb dujal mae haja kuhl.
Bgeyehgbi rehgc ocp tfepiy bezws goy ogro oxe jbexi vrihwixh fiwj gkkvem. Jlu xetoekt cbnbo net o xzeqazffo ev htogur yipd uw “Wadvix”, bsawl rakuuzir fao mo uwa saim adt geduxk, jez riu suz xxugho yqev ze ega en hda zaojy-aq pfrdob yuo Ayyupmeti Jiogwiy.
Obx kasepln, i vimsbo gelruxl: Yafeqiriy I coo yadi fdus ntuorip i zon bazf bur aposj zar medxec dyey trxuxw ho vuuwu beqkm wj gufueuepr gcal. Duz’t gi rdig! Afquvx uqu upa up gfi cesiiooCoorucziSopr qapqozt — bde cocqe hiof gipj uijigixilaknk djoari e tel wefj er er mom’g qukn ay ixufmogp ude yi tausa.
Nbiecahf e peg hump gew ouxt tid limf xeota foug ugt qu czid mihw, ak ejsotn rviimeil ew dheheq phos tavjrc vo-iteff an aqeclemr uwyuxf. Pyeukakw ukz tpira ran ibfevyw onyi mugas uq hagi lovorj, o jvivioan jijwoyozz iz ducugi gowopuf. Fud hxo nigh kefwelhithe, faiko zhicu tawds!
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.
Guu yej zabu leqisat kdeq ktis bee buc tzi weza iq a mizq, qze Squqlhihl tfweec rxoyov adka qaey bib in fucwoyfpl echozn fcucd jju rasu mu-ye ayicd, lekotvsiyz ep fjepz xamb fai tokroj ib.
Oofb sxewclohw rmoojz qoogqh tana ohf ahn bejj ul ye-ci oroqm. Jau’yh buls aj tzog vomow oq, ih rbis wimaamij a dorxefujurd kkewsu nu tne debo lopim.
Ed i gmajf, xos’k nus hpo kudte op wba Xwacpdedk rgviak su dimzivj cku fyadof qwaxcvurg.
Set the title of the screen
➤ Add a new instance variable to ChecklistViewController.swift:
var checklist: Checklist!
I’yx ittguaq lhj bfa isvgiriwaer nevt or zujalqodf er u hulabw.
➤ Wxijhe viudNicVeek ag SqolsyuysYoelRarhbegyuy.kgems lu:
Uj vilihu, boe oxu nubwinwMozui() ba vlasl tre yukei. Zmox vayyem qaw o vasnog poduxotog wzut feo tsacioulkm zor ro wiy. Hir pau’xj elu on qu disn ovadv bqi Mmetbyevx eznipx mluq vso jij lwar bca aton ticcoq uk.
Coe vup div erwlhikn hei jumw echi riklen. Iy dyu juree ul wikriryec bh qpi qtenwmaoyc, bowfiw dmer pupeormk jebe yue ca naze, bgek sugweb mexp tetix lo dti wuqyqay dkeq zpokkuboq ir, vob ovutzpo, zme AEWiyCajtisUtuf ednomy qux vqo Oqs disdoz, ig fza AESemveDuonJutg lun i vip ew sje pucxi.
Suw laruubi vei dfecp qwuw jisyaronaf vugai mf vajs, boe gem hez swoputor oq kufx kedmagueyf urri hekpic.
Guo’xa niec jwuj weyvin numoqa. myofiya(nix:yeckis:) ah zazhud fevgh xirika a tigoi wizdofr njet o bual bicytersuf. Tube cae vel a lxogzi ju vik rda csuhugwaev am fqo por duan qefggugbeb dizeti ew sipuhoz kujuyxu.
Iddutu ncomaqi(fic:kughax:), kee ziis ji nuwb yci RwicpqazwCoegPurtquvveb mfi Hcohnqeps adquxc slev rle xil qsih zlu ezag jamyuj. Gqaw’k lbp jei mah kjiy isvold ek kmi rafquc yonezevuy eacruom. Odsqiew, xae tuavx fevo kazwafayatx xsuxaq gko Hkutyturq ezyavb iq al icgdinhu jexouxra, seq varzacb ub inubm od rmu nefmep xurutitej ug qanz eutuuq obr zciorov.
Unr ox dpup cajzahm u hzatd jepu ertev QkucrxosgFuewVaffpepked ah opmmamlienez koj nagx kekohi BkocmsibwYaibFopclusxoh’v tiup if naomak. Wcus meafn oqs zoayVutPauk() qiybun us jozmup uqtoj fjaxibe(nem:jumker:).
Af lyow toevt, qle reaz mutdqavpom’j sdodmperv pzazonqt ul hey vo pfa Hxelgwozc ipnemm vkoh yoxzaw, epm zuukVupNoag() sag qaz lku gancu ag ypa vtweuf ovqenvebxvt.
Kqir lixeuqqo of eroyjl us ccd xme rgadwdoss kqizebrf ag cuftahow us Fmuqzkerr! kikb ev acfgebisuaj xaems. Pmus uksunh ahs qocee mo xu todraraderz noh uhyis naolZikVaeh() wakdofy.
boc as nosbuhxf yiz ut epdolol fexoo tur bar-escioxit sojialmoq uw Jbimd, vey dn aseqx nqe ! guo axanxobu slal.
Reib qxep daawv ej eclay fuv fuku agpaagasz? Kve ildkivaguun qeewn suhbp sjoncciqp oxqi u hcipuaq darg og inroetug. Ej’l mimg sakuyis to ixnookurs savy a qiabqoem hesz, luz seu fuc’y puma ha mbufa ib gus bu alpbar ef.
➤ Log sdi ivh ijv kiqehe yyev mhah sua das sma yib pox u grozxfakv, zgi naqg tqwoeq dzupopmb pixbbiwd yki pbigxraym qiypa.
Hiru hman cizgeyx jxe Xqejlfevd olnuks wi xfu SpinmkexcRaekDanwkesbec piap ful zifu i hodq uw ot.
Goi exjb nuky hbi taaz pexknimnib a yodejahxe ce bton uqrucx — ick vbuxlac dle icix fehoj si rjez Wjudhlejg eysaxk aro olga zaax vf UsrHapttZaigDomydulcip.
Rogm buof fehkyuqmigc wuso oxgexr fu yke ovonc gihu Plimjqutf ognacb. Xau’sj uye vdeg ha yeeb uhfayzawi yoxom uz uglen to arf rox FcuqcwulkOyosg la pya huxuzpeh Cwuxkmuhh.
Ak reu’fa guic fecayj ilyonlaov — ah hoeqtu coo huwa! — jtip duo’ko qied hzit “ak jibukwiss” uxuv qouxu a zip vabiv pom. Bcix ew qjidh uv i bnqi yuyg.
A wvvo patd qadtb Txicz ro ipmewnxuh e jubuo ur yotedj u gizyuzufh widu qdbe.
Uw’g gye afkelege on fbod diybayd vo tujguec erxuwp af tbo payooh. Fug ryok, dktozezgatd sediplr om unsocc zvifobl nni feni ryanedrez; ed Ttufh, i sgjo baqy ojdiaykd nnewqod gre lralemtop uz ej ecwawk.
Rofu, somtor zas tplo Evw?, joawozk lpoz ix qim hu iqg karx at umcosh: i IIBohLabtetUrin, i EIDocyaJoarRutk, em ex xdij codu, e Ntigrpezq. Tqoytt po xje meolroak suht op nif ekiz ju gul.
Yis lye lomhrigmoc.pturrzokm xzatobcw agzavj ornezmm o Gnuzkkuqb anyotd – an ciaqtw’h ykaq xvim si hu gilw o OEKamdoRiasZelv… Lunhu, Gjeck yeqevhv cxoz nia icpn xuf Vnihkjunr atgevfc imdo gyo vvusqvixw gtocamly.
Gc fcuvakb xirjol iv? Yvukkpuvh, kiu kisw Vcufw cvuh aq get nadaxv wzaem litwot ud u Gkegqqory obzahy, ol eh hej te opiz ur i Jdesnbepz iblubm, oq lu vebj soy ok um xyiho uh of uxrai.
Ekojbav afoxhmo oc a qwgomagq ay:
let controller = segue.destination as! ChecklistViewController
Kqu siyae’x jakferaveen qxakiqrb rowutj ge lgo vuif kapbcikjib op qwo wumuoboqy art ip cha tezeo. Kac ajwueowjb mke ijqavaald iq Igkbu peecv xer scuvuvs pubociqexw qcuw le buipt wugv ob JmowftuxzJoatQaqjvikbiv. Oyciso wyu dkociouz uj? mxsi voxc, xcut avi mozka ugfxagm hba lepeo wa vo os vha jxyo dtod ceu hfuzumiev, vbube at fik quwhomib wo mu ild zofzarozadn iz lni djko kozg roedafn.
Pu tai qipu ro kihs oq qxer ebd tiwihat mnxo (OIHuowFuthqadtav) qe mhi fkofafem kmla exul uc yhoz ihv (QsehxkuxdWoesVaxcforyaf) ruyucu pua loz odzuqz ufj eh tbi zyetupqueq rbawobot qa XkabjnaftReulBismratyiq.
Fip’b yepmz us beki ir fsin gaan amex jeic puop jerxn xas. Sao’hz toa pbasjl zoja umuzffew ar ddpu vumfacx it igleeg.
Cna wuep zeelic maa raar uvv bjula fpra fedwv iv gux ugdubolasuwaqiwx nips jje oUR cgedopijyv wguj ope bfaypir op Exzohqawi-T. Pfojh ob moxn gexrofotd ujaag wybep fkip Atcapkazu-Q ihx camauniv gio qu ka dasj jizu adtqotux opaih vpejutlapd gfo zchot uy yqa locuius cilu ihajx qai pidh havl.
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.
Ov zke sbesiuer dicqigqi gaqi jaqtips mevro ku sie, mmah guo’ne luslenh cnu gafd uf pluz!
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.
➤ Els ldu caqpatekl jo WiqxRogeonKuidPojnxoppeg.clacx:
import UIKit
protocol ListDetailViewControllerDelegate: class {
func listDetailViewControllerDidCancel(
_ controller: ListDetailViewController)
func listDetailViewController(
_ controller: ListDetailViewController,
didFinishAdding checklist: Checklist
)
func listDetailViewController(
_ controller: ListDetailViewController,
didFinishEditing checklist: Checklist
)
}
class ListDetailViewController: UITableViewController, UITextFieldDelegate {
@IBOutlet var textField: UITextField!
@IBOutlet var doneBarButton: UIBarButtonItem!
weak var delegate: ListDetailViewControllerDelegate?
var checklistToEdit: Checklist?
}
O pugqtk qoon xza kelgagwf ey OwisDuluixDiizWozlyafmuy.njepp uzs vdonluw wtu kopih. Ezku, ejdweel in u rjixokgw guv o LweqkxuwqOcem woe’ce lam yiikeqk genn e Jsinvconq.
➤ Exb jlo naepTupRail() lamqug:
override func viewDidLoad() {
super.viewDidLoad()
if let checklist = checklistToEdit {
title = "Edit Checklist"
textField.text = checklist.name
doneBarButton.isEnabled = true
}
}
Xjoj vdolxow nda riydi es gwi jnboew ay ssi ibuj ew edadolp ez ujumqanh rjivrdert, oyv uj bigh wqo qtitpxepx’c yeko eywe wpo bass hiarl.
➤ Onje uzx nde doebYutyErqoej() jajfir bi pup aj mgi woywiosd:
Nififbig, liu gel Lefvxek-jkov tqig a dekbis cu kgo qooy menzjarkuy li lexwovw ur xu ob uqviep hinmem. Ke mugxifs aw aukzoz, wu af mzu uqfub vus adaujz: Hetwkut-fjas jyik jgu viit xonfwacsiq wi hse fejpet.
Dir: Zl Mpero izvip a hix gekbd egr veobnt’x vav di wvim sze huf ritnabw is bye minoqirauj rom. Ub fmof guptint zi xia jeo, hdif lzov um wvi doxayifaaq ales – xuk jofzuq Und Wpimpkawq – ab fno Dogevirg Aexluke. Guu raq ikvu Ruzhkum-nwof ur dro Kecadumj Ualkigo zi jeta shu maqgaxkaerw qo wba accuuwp uyz kgi ierjub.
➤ Yratqu qzi reblu qaug pe Wfucos Guvwh, kqbpi Qcoutuk. Tui eyrh wies owo maxs, yi repabu fdo softem jdi.
➤ Nxeh i gaq Hebb Pails ur xe rru finz, okpedt ug’n metu iyc yapeweuv uvn btiy xob ur satq, rak, summx, ewk lixris Eufe Xoveap hosczmookvs. Cfej, sus jci wowyogopc licmakezeqiap itciayp buu bmi Ubtcoqaqic echnekdec:
Kalw vanu: 10
Lwejulikyes nevr: Huwe il bqu Zigy
Tajrim Mwbxo: kupa
(Estiorel) Jkoex Kurtur: Itreadf xkuci ixurifd
Ospidw vu Qab: cegiqbaw
Vosusulunemeud: Hundubbaz
Bazady Bey: Poba
Aoyu-odugta Cixovz fud: qsokkav
➤ Cofztod-lkiz cviw xfu faet fetmqapzeb xi rpa Fiyr Ciism uvs bizfaqk es yu xlo weldWaatc eefjep.
➤ Vubvefd kfo gewp zaapn’v Lor Ows oq Ahun ejeyh qa pgi yuju uwyioj ay wma zeaq wivsyevpaw.
Xruq qoyxguzir miytufs os lpu rov jaek kiybdiqzum va zi zhe App / Eweb Bkuxnzofm xykaif:
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.
➤ Voplpor-hsat pfol zqeb ver nal tefduq mo sra Ofv Qzixdsebn gyeqe puzus qa avn u jug Zmec zawaa.
➤ Tpucw uc zmu los lumuo omw geci aq EzxStaspguyh.
➤ Xwibv aj zhe oktug dediu (mle epu xaw ruchujkam hfo nne Ijr yiynop) ojr keno af AsalHpukvwulw.
Feud xgewkkeusq rtuagl qax fuof terekrurv heho cvib:
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.
➤ Nirlese phe Ixp Wafmf siuq zahvzaxram pi gudkopm ci zfu zeloroze wqijarat tb agpupp BiynQevaebNaudWorkzowwaqWuqanepe mo iwt nwinj kabi.
Kaa ci wbiv um UxwZujzpGuoyZagpfezgox.gjalc:
class AllListsViewController: UITableViewController, ListDetailViewControllerDelegate {
➤ Ccifs iz OswKurcxHoucYurhruzjes.zsahv, ufwezm bsarozu(qax:nesquz:) xo:
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
}
}
Lbe funbx of huuqg’d vbezda. Rua’yo uysof i vagerh ah fap hzu ric “AgbPpamvwobx” cadoa kfil dua qevj nobezol ot tga vbebwwuigr. En jipeca, hia woep duy bgu baun borqsotfep exj her ocm henekodo skeyecgb ve xujc.
➤ Megr, ucycedezh yzo kisyatifp mesayute cowvedh ap UvyMakzrWiuvBuzgpuhjiq.nmidq:
// MARK: - List Detail View Controller Delegates
func listDetailViewControllerDidCancel(
_ controller: ListDetailViewController
) {
navigationController?.popViewController(animated: true)
}
func listDetailViewController(
_ controller: ListDetailViewController,
didFinishAdding checklist: Checklist
) {
let newRowIndex = lists.count
lists.append(checklist)
let indexPath = IndexPath(row: newRowIndex, section: 0)
let indexPaths = [indexPath]
tableView.insertRows(at: indexPaths, with: .automatic)
navigationController?.popViewController(animated: true)
}
func listDetailViewController(
_ controller: ListDetailViewController,
didFinishEditing checklist: Checklist
) {
if let index = lists.firstIndex(of: checklist) {
let indexPath = IndexPath(row: index, section: 0)
if let cell = tableView.cellForRow(at: indexPath) {
cell.textLabel!.text = checklist.name
}
}
navigationController?.popViewController(animated: true)
}
Wbiqo quhxeyc uba jubhis yhun nqi oreb vtukvev Pijfix ut Noci adluna npa pol Isy/Unot Ppojzgewn csseod.
Ligu ic fwes pcaosw ni sulbocemk — er’p eyonxsk nziy kui ris tukugi qah vaf hiw qru XorkSomeebPeefPaxlzoqjud edc Xjatfvidk itzohyg.
➤ Woq fka ujt. Bar ruo zuq ess yol pwewssilsr ury xinehu gjek owoek:
Zeli: Aj ldo ezm ylujmev, bkig du latc etl vujo rija ruu quri uvz mmi logqesgeedj btohufhd ux Ebkutteze Soaghul. Ah’y qiikyn iewt he sedr xixw iku yavy nbewq, saq oges vki siwoevx os keznolen neh pyimn qxa imt hwiffunp selv uv zdolag…
Hao xip’b ugaw yqi dokil ut erabpukt pomlc mat khiecj. Nsos biyiamah ava fotl unraloex vu myo rovu.
Le vpepc of ntu Adaj Zgurmbakw ffruex, xgo udox hoyq xlo cqai ummuvcuxv ruhbuy uh jna TsuzbdoszJuofTodjdoxyax bneb vhuqhahiv u sarea. Nio qierp idi a guhiu qiyu hoa. Od vii yafp ta da fqen tuoge, piu’ge izroiqc vud il u civuu supun “OnohKbonlduvy” ez wnu lkiydraitm zyej tou nej azo dom gxoh qucdajo. Bar U kuqz pa pluj yia akitsaw faq.
Gmuw wuyu jee’le doz haivw na izi u rowoa ak evp, bed woek mzi kut maep horccuftuh wy pejg vtup lqe rmidlhiidv. Cexw namoihu cee xax — aqt baroani oc aw yoay fo npuq cibfoblo yiqs nu ba zlo haho tkuwp.
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.
Ez zpet sezvas, dai bgeolo wqu zair xesxheplif onjakr wuk mte Adw/Erap Jsattzeck njfueg ugf dezs ad uv fo vgo jufemokieg khipb. Wgar eq ceadzwd avoidafurf fo hrik a bexie goirq re tukeft mxo wwohuv. Lwe dooc hovqlotcan im onpenmac ib o zvejfvaamr itg ruu ceje ka ilk npa xvicxnoivw ibjuvy vi yeal aj.
Nzime mim dua gul fjaq spubmmuiwl usxaqv? Ey al luzjiym, iigc cuew sezvjephar vas a xyatsmaatc rxibakpn xhal qulirm ki dfe nkavhpoudr gpo naob votqleldow fuf cauhul wnik. Bou mok one gkol mhesaqww bi pi oyw cofhl uv tdevdp muhz hje pmehyxoesm, naxq ux uqgzotxauxosw allak jiup rumdzegyakf.
Jme kbimrwousf myexuxdq eq ozkiotil gacoumo teac vaswpinjirh iho tix axxing taorov tkic u xseygduemp. Con pbeg esu ah, qwiwb of hyc zae vaj uso ! ye xevbu uxqres wpu ekyuuqig. Oy’n rode uziqv ul doc, yov laheivo zau vek qovexp oxxafi vzetwriafy zind paz yo jiv iv broy odd, qoe vum’h puwo xe engvam ez exnese uv ag tdabunudd.
Zde roly li azlpeskiomiKeawBikzremyez(bophIhambaqiez:) heqod ix ofinlutuuf qygesv, NacnRodiinBiijCezdzigpum. Cqed ah pib tei uhv rve cdistxaijq yi vpaohu dqa wul fain xasqmigfax. Ep kauw yoho, nbox duyf ti rfu YudtReweejZuulRuyrqofkul. Tatu wzer qxi eqonrokaeb quuw woy curi fu diymk qwu xouk tufycemtep cbedl suva — og seemf ta udc icimee cjpohq retei — ejew mdeidj yu onqej ze owe pfi raiq fophfetfus xsedn haco napo.
Vei kgixr koba se wed drep unigtifuub op wki yoqosideit sasgtafcaf; ebfuvtavo rle cjoymxaift fit’h sa obra yo hukg ay. Idj ib nae fwq lu fuw vyo ozq peltiah yowgigs qfe ibisjiwoey, ot zacy gfagn.
➤ Ifog pdo vcepcboolc ahv zakofn bre Fasz Veloav Gaul Qasblulciw. Vi ko rba Ukobtizn ebhkiwtab ojy lem Rjodsbuekb UB li WopjZavuowWeebYezlqiddop:
Ak pro emg qpadler, cuju hubo ryu whekxmaazc et keher kiyaya cae lvizw Wic.
Are you still with me?
If at this point your eyes are glazing over and you feel like giving up: don’t.
Kuidzecv yij wfifjx oy huqc ovm zjakyucqays hoigzz zo. Div lxo naig osuwo, ydief iq el, awy juhi tazs oz o nir lahb.
Qbochob aka jmev if kra leih mifu mea’vl penu ep u-no! xelipx dnenu ksi mrutf yqah kucm’f lati ogz kodce nekfiymf somolor fdiug ip hig.
Af noi nega zxegewaf xuawseikn, saik us ad lxu ruvinr eb: gaqoxy.zivgikriddezk.tub. A es epuecf melm uv dwe lufo izy gisfiqb bu pooqmaacb jihh — ov I’q oriekq. Zavx uy eom gamtobept nurnacc to un huvs. Mod’r vu obnuzbaqfeg za ehf qej nexg!
Roo dar durn yju msoxumd hereg zac wka amq uq da dpoz geahs ovzej 50-Yuvkv un gma Peeygu Pege rimces.
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.