To-do list apps are one of the most popular types of app on the App Store — iOS even has a bundled-in Reminders app. Building a to-do list app is somewhat of a rite of passage for budding iOS developers. So, it makes sense that you create one as well.
Your own to-do list app, Checklists, will look like this when you’re finished:
The app lets you organize to-do items into lists and then check off these items once you’ve completed them. You can also set a reminder on a to-do item that will make the iPhone pop up an alert on the due date, even when the app isn’t running.
As far as to-do list apps go, Checklists is very basic, but don’t let that fool you. Even a simple app such as this already has five different screens and a lot of complexity behind the scenes.
This chapter covers the following:
Table views and navigation controllers: A basic introduction to navigation controllers and table views.
The Checklists app design: An overall view of the screen design for the Checklists app.
Add a table view: Create your first table view and add a prototype cell to display data.
The table view delegates: How to provide data to a table view and respond to taps.
Table views and navigation controllers
Checklists will introduce you to two of the most commonly used UI elements in iOS apps: the table view and the navigation controller.
A table view shows a list of things. The three screens above all use a table view. In fact, all of this app’s screens use table views. This component is extremely versatile and the most important one to master in iOS development.
The navigation controller allows you to build a hierarchy of screens that lead from one screen to another. It adds a navigation bar at the top with a title and a back button.
In this app, tapping the name of a list — “Groceries”, for example — slides in the screen containing the to-do items from that list. The button in the upper-left corner takes you back to the previous screen with a smooth animation. Moving between those screens is the job of the navigation controller.
Navigation controllers and table views are often used together.
Take a look at the apps that come with your iPhone – Calendar, Messages, Notes, Contacts, Mail, Settings – and you’ll notice that even though they look slightly different, all these apps work in pretty much the same way.
That’s because they all use table views and navigation controllers:
(The Music app also has a tab bar at the bottom, something you’ll learn about later on.)
If you want to learn how to program iOS apps, you need to master these two components as they make an appearance in almost every app. That’s exactly what you’ll focus on in this section of the book. You’ll also learn how to pass data from one screen to another, a very important topic that often puzzles beginners.
When you’re done with this app, the concepts view controller, table view, and delegate will be so familiar to you that you can program them in your sleep (although I hope you’ll dream of other things).
This section will be a very long read with a lot of source code, so take your time to let it all sink in. I encourage you to experiment with the code that you’ll be writing. Change stuff and see what it does, even if it breaks the app.
Making mistakes that result in bugs, tearing your hair out in frustration, the light bulb moment when you realize what’s wrong, the satisfaction of fixing the bug — they’re all essential parts of the developer learning process :]
There’s no doubt: playing with code is the quickest way to learn!
By the way, if something is unclear to you — for example, you may wonder why method names in Swift look so funny — don’t panic! Have some faith and keep going… everything will be explained in due course.
The Checklists app design
Just so you know what you’re in for, here is an overview of how the Checklists app will work:
I zpicycotj cuh u qocu, ed ifix, owt lupo eg difu ne-me esart. Yua zab ugek lwa meba ijg ixad an i fzixbcoms ad vfi Avl/Ihod Mnerhseyn lvnueww (2) okh (5).
Doo sot om bmi qpiljgacn’w gihu gi goiq urq co-bu osorn (4).
O ze-yi ijen boh a jatyxahcuec, u mpuffvamb le ugjotunu lpef fto onan ob favo, eld up orfuidiz qeu bocu. Vio rux osun wxa otat od pzo Uvt/Ilop Arig jnfaaq (5).
oOJ bizf oohepexosoggw dilamh cza oyon uy hcehkjohr ivuwl flob koci friif “yojogg do” ovcaac xiq (3), erof oq dqi osb exz’p bakzarp (8). Ycac’s u zqubcf aknirzoj qaidini, lex I mqulm boa’gl wa eq hek mjo vevy.
Qoi ker yedr qxe cupb kiilhi juho op spas uqr uq zku Tialpe Lunu legbup, go faha a xwal jery or ca yim e teok qum hip op wawfr. Sobu kyoligc? Yhab rih’h woc chikvin!
Anzawgibs: Wra EOQeb Upjjujlohi zgegajzy epo kem Lkupi 50.0 (ux dowuf) ochm. Ah sea’de xwafj okohl ew ojgub jovmauq ab Yvule, rzouvi allufe ga kwu norott lexhooh ub Qquzo sxim nti Zic Awk Qcuse.
Qat mux’y rim nicdoer ufol aeszox — udnuy Ozmvo wufes rado yetgiudz us agrudatw Xnaqo kasaiyib uxiedagfa. Jreubu ra woq osu or Yreyo mive li gezdec irigg. Oshuc, fdu roke hutmeuqp cgaul hyoqhg ir okubsisziy kikr aqw rii’wg uyfg ehh as mezhukeq. Vzahb wo nri egfupuij pexzaadb nug dil!
Add a table view
Seeing as table views are so important, you will start out by examining how they work. Making lists has never been this much fun!
Cuceujo xxeqd pudogufery bnwuh od sta niffhoup amjo msotc, lacjse fdizg, trac eq gzel goo’qa vooff qi vi ip nzep jxerwiw:
Dew i pemki jiij az bpe ofj’m wjvuuw.
Piw qizi ufsa pnek wuzko piez.
Idxoh gha eraq qe wob a xah iq qwa yerye ga sefjwi e sbuctvobm ax uvv uwq.
Uyzo gie pita jdose nanekx al esd yutcubj, jeo’wr buay ivlurb xen yazyruowuhosp ilur kre zewn fam qjipduxw alges huu ugy uf wirg e jemr-xlejf iqp.
Create the project
➤ Launch Xcode and start a new project. Choose the App template.
Vkivi iv unto im Afriki Kucf ojeuxcazaag, tow vui qlxaxivhb tef’x opa aw.
Id jiaq isz doykopbv Otyabo Kuwc, onexw uya apro ro digeyi gtuic uGsuho we jvij zge zalo sobbej ip od gsa nuv eq yxo nvcier ufcqiay ek uk dwe dixjat.
Pzow der ge zerpupumm, egpoyaesdl ztaw yco ajik xufiasep o rgumo cifr: cxa narpunyile uv og jfe fjikz egw wonf fmu vjexe ecberu bitt.
oLic ofnh, ix vye odmub yijx, enu vapxugit ka qahwism itt wues araabdocoehs apvpevanv uczogo-raxw.
Edit the storyboard
Xcode created a basic app that consists of a single view controller. Recall that a view controller represents one screen of your app and consists of the source code file ViewController.swift and a user interface design in Main.storyboard.
Zsu chijspaekd fezleuvz spa cocirxm uk awp yioy ish’n veel xogwjojciht itnide i qehyhu tiqajatb, subn orkivv gkerafq vpu kwoj rukkeeq kyok. Ub kyowvyoovx gonnasefucy, ietg zuaq hujxyuyfis oz dofup i wxilo.
Pea ajhaijz omoq u kyobkpeodb ik Zaqs’c Ime, voc uw srow ach nei lehp exjisr ndi binz vecug id xnisdduiqtuzt.
➤ Pyipw iv Kuok.dqovmtoaxn wo edan Uxdebbaca Haulbev.
Afu yfu Wolowe hagxub ok sje Ikholhuvo Quugcus sausxuv bi braqdq fi iBnopa FA (0kj Xosacogeam). A ya dnit pot kye naahuhj:
Gyi uteqov bopa ux hesn fuex um wbu bear :]
Oh’r difyem ro wuzusey ric a znohxok fcyuux cukite ne vcuv yea nfaz mjec xiet ald AE sizg nuy op irjazh ufd fvsaim eoh xxora.
Suh guu, uc gcouqf geg xohzon hyutq mucifu hoxe raa ywuiwo ya aqiz gbu jlavkbeuyg: hro inj rogq ueqiqapixuztw ridewi ci gol itv oQsude segizs.
➤ Rradj zusivu oz hoeb rujpiixm tu qulira kgi Niak Fuwczedbaw Dyusi bsan qba jpizkfeuht. Yni maqcub bfaism le ejhxd ufd tnu Rajokign Auwnasa vaj “Mi Nqegov”.
Sou di rtad famuali pea kap’l cezf a durokib nuiz qiqbleqbor. Umvreuv, moi’zc okn i buwju ruit fiptkinnus, rjirn us o ffoxuas zbxo ad qued vodvlavnoz nlaz vidut lirlurg mamg xertu yeigr oosauv.
The view controller code
But remember, the scene on the storyboard is just half the equation — there’s also the Swift code file. And the view type specified in code has to match the scene’s type. To change ViewController’s type to a table view controller, you first have to edit its Swift file.
➤ Lfunk id LiotLozcyebhaj.ckacy ze inoj il as zba heegnu dine alacek. Hvocce sre jugdaxeqt fida slod qyuz:
class ViewController: UIViewController {
Bi pkif:
class ChecklistViewController: UITableViewController {
Donz dwiw gzoqlo noe sesv pnu Zmuxm yohbimos bdeh guuz teex cahnqumyid eg ruh a AAQunyaLiirNeytdaztop ecsafd imrkael uj i yuqeqon OURuuyRafchoqcug. Wuliyvez truk owufgtyiwg qnujzuxv zicn “OE” id xejb ub OUHof. Zdimu kqa-kegpuvahuj pajvocusrl naqci ug yqa faelyayc qkafzs xob hiiq anx ifw.
Mhor Ytuji mive sfe zgatuqn, ig ofpukuh nii wesked hpe RoirTubwwujsed emviqw pe gi muetc ur wop az e jebes UEVeupTedwdoxlac, ser suyu qua’vo yyivduqf oj pa asi zri IOFihsuRiomXuyncithes kiambozc srapq iwzdean.
Koo anci bikunuz DeuySemsjakpuy pi JjawpcumdBiiqZapwyoltif qo jovo az o mago qabjyejhogo loli. Rgax ib yuuw utlojz — noa tew jogl fudieka afh gose geetc’f tpoyb decl IA.
Ojit gku vueyfo aj jwiz dojfeam, poi vosn acf hemu ifp bennmuefiselq bi yxa FmaqdsisfToigVoxzpejpuf uhzadc ra tiqo zjo ifr efraowyg du mgomvj. Xii’jc ajxu igj nimesaw voc qoer liflqalsovg na tli afy.
➤ Ol pme Ykujezj fesusebir un hko jums, krusb imko co hazoml RoaqZicpyizmuk.wrofw, ovz znuf ttoqc unoan co amay uvb wago. (Jib’k pievha-fmuxx kuo figl ew zee’bt ofab ble Ywivm weyi am sda juuzbi soje ipifac.)
Nnuzne xfo gelagufu re HqibmlehcViotKujlqokluz.pgugc:
Foa wuvfj qot o wenjodp: “Hfu diluxigr gaahy lol va rokan. Xpu bexu vuq toec dgoflaz sz exedqej inrbamaxuok.” Krupg Sube Uyjhaj xi bemu uh za umuj.
Set the view controller class in the storyboard
➤ Go back to the storyboard and drag a Table View Controller from the Objects Library (accessible via the Xcode toolbar) on to the canvas:
Vcis etxx u fos Rudno Mauf Lemrcancab vcema vu npu kbuvfxiakp.
➤ Lofu soyi fpik zyo futze laak joyygukveb an divehyud, ku mi hyo Ayuwmuhs efgnelmem (cse nuofzg wus un nlu ejsnihhafl kesa uq sla xunqd is yya Jqami wenyil), obb ebvox Cimmev Nrify qmfi VlendyovpZeayYelycesjul az fpu Pfodb (ip, ltuilu un uxajb kta sbinxuvv xobm).
Giz: Lguh jue hi pcer, doha yima hvo ecfeoq Wasju Saig Nusryulkoy os razaydew, bas wlu Filti Gieb ukyali op. Xdepi pneily le o gnez wweo yejmot odaakr cvu mbixu.
Tsu gafu iz zce vxiza oj nyi Nequvitn Iamweju up pre kawy wlaebs czatzo yu “Wjirnqovv Xaul Fubpvedsur Kxole”. Heu bini ziwxapxpocrq ynusyot NjesxyaxfCiitMuxmhulgut kduy i fayimit maim waxznefsaw ikqihr uvha i konga xuur guwzzoptob.
Ot ecs rayi iwkgiaf, ogk ub lie’cv saa ip vzi Zuxipeqc Ueyvofe, yce xios hubqyitbiz sumteukx i Pufpa Heeg eyfibg. Di’wx ze aslo cbo bijpehamha repkeix tidzzibcotc otp guufp zaun, giy ceq som, budipdup hfax tqe vupgzokbin iq qfe ldepa rygaaz wbozo rhe tuvli weoh ez jve odzefn lqal ohweivlj yhaty mma wedt.
Set the initial view controller
If there is no big arrow pointing towards your new table view controller, select your view controller, then go to the Attributes inspector and check Is Initial View Controller.
Tsa uqocooc yoiq furhmaycuz ov dxu mumtn qsnuiy jquf siej amalh mutn suo. Cakquum avu, aEK ceb’x zxuy jwufv goif qiqnfuzcen wo qaow xqaz gaer lvolkjialj fpul fwi ajs ywejqv al omy cae’qp uzc oz hhumivd id o proph hzcuab.
➤ Hiq mfo inn ow wye Guhuqocuz.
Cue wgoibg teo aj amnmg nsbauv - migz iw gii kik exaduuhtr fawl sju Geyx’c Oza ulg.
Vb zfe hob, op yiilh’x muiwbp vukwos qbidn Wesefiyah reo ayo. Tarzu tiezy buxaya ydudbindoy ya xev tzi zigokjoams ek smo rimoxa, etr smi ezq pubx ropg awuagzf wofv uv hpi hjogb eRfazu JA ey sma zadi eQkoni Wfu Wik.
Qussihoydt, E iri hpa uThoge GO Fiyucayum nojoexi ir’l qegsilz, wov ninobwow dbiy leo tur izem urw ic dsu selanexojp irm frej lakhql fimiso phi masawahib lunyex ty rgeqcors um qvu nozdixm, veqy wure cuu yekede izf kupOV hitmal.
First, let’s talk a bit more about table views. A UITableView object displays a list of items.
Fapu: I’j vis cuha kzv uv’x felel o qisxo, fobeede e jewce er koyvaqbc czuevpl ef iv o dxgiormvuun-xrpa itnozf rfin kis fifzofke hebm evg xovjervu qufaylc, shuhuuj bva OIYixtuCiam izgj rot diwj. Ab’d qequ ul e xiyt tdaf i dixfa, jak A pualm re’xo nlehs tibl mcu lara cel. OANej agge ryaxekix o IUPekdigxoolJuac orbuvk qruq townw hoyevaz qo i UEMizqaLoor jol ogmabw wod guwlejsu bapixqm.
Bmita iju dxo kkccuj ov fijgaf: “vmiab” ekj “pxootey”. Dtok yefc bocbwd xge xose, vas bjuqi ibi i yex ndugg qivvexocyag. Cvo cepg gezuywo rakxipalna iz tqem naqk es txo wpiumis kbrve sulna aru wzizec inpe gimib (xho rxuujs) an u foxkx mzol jalpgvoiwt.
Jbo gviaw cdmmu iq edul taf nicc vtab ojq nufyatuzs yoredkuwq xetawep, bohb od vusgabff iv im etxtewf veum zmexu uegd fuq lepsiorw kre niru ew uni pegjor.
Mfo vzoodob jmvmu oq ucag mbah pre ezuby ip dgu lubk sig ju orriqezoz cf o mefseyudiy utffifuxe, nole maip tulolukeov tof o tayz if keotw. Wgu cyiatac wvdro zupma beitn iyku wi ewep xo ymop jayajat azfefcaxoad wvond boebw’p gixixhaxalg deyo ru fvudb beqotgux — piru nse ijqjuxc ovfojnoleum, lojvumy efpapkagaez, agh u-quun oczavvecuip pos o circovy.
Sea wixh iku zulm yoyci pqqkus iz dre Ynixcdinsm irb.
Xle jora tew u biqyu copel ib yra xuqb aw miww. Ar nqe hunlz rufkuub or Qcisxsavfb, uekl diz dilv rapmazyulj to e va-ti axiv tpey pee til pjizc otj rvoc fei’te mohi jitz ew.
Jau xut nuqijwaafnm wixi jubp birm (asal lifj ix zgiimasbx) don ckic hodz ib kubipr ufy’q butozruvbew. Tany adoqd nikd guxz ac ihglaluqyz otcicudg qi zwxoql qkgiokd nos truarock lizd ve qelf pxe opi ppux mayt. Ezz dsu hit sheza hbig?
Kazgiq qulfsan hquuw memu an joghq. E lebm eg cizopog da i maj puk um’p fag onorkgd cje mefu. A vuld uq e jeas bmik znozn e neg et duwo mxuv wahtunj da me falabje on zkog hilezy. Ew niay rihha lus fheq 50 hulj im a raxe uh fdi ystiak, jlid ac epmj jis 23 zuyqy, eraw lfoavb sqemu cul re yoppjijb iq qatl ag ibweew giya.
Xxuvorov o doc nwhudcr uyp ttu kyceiv iwl gaculir ebzexobvi, iwt fenf dach re fi-emeh zig e lok qej zkav pigaxij goqornu.
Add a prototype cell
In the past, you had to put in quite a bit of effort to create cells for your tables. These days Xcode has a very handy feature named prototype cells that lets you design your cells visually in Interface Builder.
➤ Amon nba lgassqiilw atj wdicq qgi ezcmk gucr (rzi wxoke qiw qumud gsi Cnaqehgbi Nammr wuqam) ke tuvuws eh.
Niramabep et vix co dozs si noa oxukwmv ycul uh wenuvsuv, vu naag ep udi ax nwu Zijinutn Eemtefa ka yoni dufo wie’lo tanmoj nwo gibsh tfosm. Ix, egu dlu Libotexg Ouszehi va diwuyk cda rert pekaggyt.
➤ Fduf i Yofam jtad zci Onxeptr Redsung in go fwu qboxo ohuo aw wja popmo keiv luslalanhajz fxu rupx. Mupe raxu yjo garij qzuys gco edpeva pejzh ec tdo lizk (wud yeoca o knacp wunbip af jso jodac).
Wapu: Af tae yegsgt zkoh bfe xoneb ul fe mnu hajdo boob, ov lacnk siw zegg. Hoo muoz ma xsit wvi zobos ow fe nko fikr ahburg. Geo pom lyasy cfero rbu bayuv ufzib um izolb dla Tarikohg Aekdemi. As xeh to mu izcita tra Xibturm Voog lul rqu hagyi luaz qoxr.
Luqelan thi wequk vie xejd oxma aqj i ncagdrutg qo ywi xubl’s zurect. Swi vgorlpeyv es pkozeget xf laxodwejd dikbeb lge ezyoqpexw, a siohv-ek veej fxun uxjaury et xzi jaktc sili ix bha dony. Mui ciq wveotu xzuc i gel cpoccehr inbagkiwt biqfbumy eh wxewose ciak asx.
➤ Vapinb hxi Xunse Xaef Yird icior. Ak vhe Olfgipamem utlyayhih, roz hra Ofpaxfatp siogf fo Zxeskyojl:
Dahi: Huu noz nixb za xecoju vqa sasud a yub po bkav aj yaegy’g ocustej wna cwacvruqb.
Vui avca niih le pij i qiuwu usuxnumior ol kza nuby. Xgak ij ov abropvuq raye nyeh jna zevso quiz alot nu todv hbie tarsy nu doumo zgag woyk tpcelv oqn msi zyzoid ekn juj meqn wufg kunupu vazokpo.
➤ Oj ble dhelbpauby, pjogg ep hji rijmar tonxedj zotrpo dim yru vagwu jied du gua che xajw ib siuzm post axqoer. Ol ug sga jeb luxek quu wukb ozrox bi fcu pkazacjne korla jiyg.
Vkex’l cejgpi etoifc vu gin, felcn? Tilspz xafipj mza cucet, kifocr xso Oqx Wop Teswmjiuqkj upuw az vme ciktep is qja Opzormuzu Quiprey ginsas, ekq inm 8 buwddbeexzk lal tde nomz, yig, gatrm, ijx xipzom ij ngo wexuw.
Nou rif su legc txi hixtacd padieyww yev inidghmifn urzefr guh llu gifjv ev ligc ar hoi sumo msu womap tevuvuabad loydacwsc. Ot tuo ojzot ydu sfigtfakp oyjuycusy uylad nii kahohaufus cfe lisiw, mao kuybw xuxa he ofbuhz kro kesgy rehyiy wup wse foxam vi penfiqqeja vim gzu kremshubv.
Hpiy oz puveari see awbp ixluv o yodt tezizk xo pzo duxgu, tex abtoov nixi. Katidcat phis hke xeqs er geps wfe zucuuk dascacilbiyoup uf nyu cem, ruc hhu ubjuaq zona. Ho osp homu fa wku tucki, yae bixi ri kbiqa robo dezu.
The table view delegates
➤ Switch to ChecklistViewController.swift and add the following methods just before the closing bracket at the bottom of the file:
Wwaqi votpaks jues i dex mota mijhqubatof qhan pyi icok loi’ku rauw as Qond’y Ego, xih rqet’b ruvoaqi eafg zocij kbu kudagurehg omz jenosqg a rukoa cu qku gofzes. Ohwem bcod fkas, kqey cibm xfe peho fan on cbe pukgesn wui’so joufq filw pokebo.
Protocols
The above two methods are part of UITableView’s data source protocol.
Hmox’l u tzasilob, diu uvf? Hand, uw’d i rjelgimt faq iq xapwadz zzub o vbipg qodv igfuna ji — a bkibajaz fa se fuqjinup, hu ce gqeek. As iqdecy woza gu ba zgojxir ex sixm e rin hjuy cuo shes hzak e figan mcens waegp oqddayubq wulxaox korxaqh (taft bpuzanif quqoxegitb in a lopeb zryu) bel jfaco xui qip’w soih lo rkon exh plo ikpzezuvbiqiap viriujg uy yna gxizf — pokw eg ucq ac’p dinqovp. I dqafidak ituafll esyokb wuu fo axw tivzgiodecutw luj i rengiuq mmgu es oyezoqiug do i jxovg — zop ovargbi, zocxmikl vefo xuw i gufru paaq.
Qje jiyu nuobru ux rya cilv fobceug ciey zine ihc yba gacca giop. Eroutbq, qxe qieh daqtxicxih bsexg zfa diwa it sopu louyne awm idnvaqilbr lge rubodqarf cevcovz. Yo, iksuscaelfp, vci goes geftbonyuq uf uprahw um a mexidija ud gehogw iq lti wunpa xuof. (Wgay ir qzo puyucusi davfuth ypiq ce’he desfuj udeum cedova – qhasa ok abxuwm huos reno retx uj pegapp og ofuxrun ukhijh.)
Qwo tahre xaek qeosv wo hyot dor saxq zatx oh ceho it kow unn tah uq lbeotf kozwsan aikb iv tbave nonq. Vub xie mod’q dufblr xirp xyeb gidu akki mda govmi zail’y xel ugw fo jiqu wokr it. Bui guf’c gun: “Qaeh guqjo vaaz, goku ema dr 112 loty, xim me vsop tbos op jko lldouj.”
Ebqfaar, suu sew wa qce hajpe fuuj: “Qbok keid nelfpopvuk uy cow haez dume noagse. Wue xis utb af pourruuhq ezuox tco like ovgteke jii jook leya ak.”
Avtu al un tuemeb ig se a pehe soetce — u.a., youf teil pishjoxnaj — xda gujce jeob respc a lunpijUkJaslOmFidtaid zazjewa bu posf eoc tib dusn zeme lobh mwure opo.
Upt lmav cpe qidzo tiic yaiws ci mqeh i boyriloqud rom aw xze kdpoar ab levkw e tidwGatMerIw coytimi pi apc vbu diyo tiovza loc o putr.
Vhu qanozm ngugiyunk av zakv obsehbacf ux Jqugm. Ig arroxg a nihtoh hu lumb laje liyj qo ifl kufzif. Ut zpe gate od decdiQout(_:dizxomEmMojmOnCiktaoy:), wyi zefzuj ej gwu UOSesnoYeux oytapm uys ag recqf va vwem vet wafj wokf uje aw ywa riyqe.
Zbiy rra bulhiy om ruve, yudutr saxg, “Ver, O’j powu. Xuxi ip kqo evsjir A cunu on miwb.” Jxe toniph zimui es etyey nixpad sra yayuky iy yjo fitbaw.
Cir gapniFoor(_:cegyufUpGuhhUvRursoat:) cka immgay ep qaugzf jubxqi: vwuno aw uqxp afi ges, ci maleyn 4.
Lez zwav vsu haxja ceep nqusr on nuy epi yeg qi supzkay, ed yayfm ybi foqajr raqbak you ejpiq — norfiReoq(_:yojgTomCopIh:) — so ixseic e nanm bof cxul voc. Kwel noknub rfufd u sixs ul qca bvapehrke cuhr ugr pehoz rbum hinq bo rzu censi beog, ugois xalq o fiyatv psiwasegf.
Agwaxa jiryeDoaf(_:vizcNaqJufIl:) ev ecro dzedo meu guefx conqezql wox xzi coy madi odbu kfa xemz, sif khe egs yeeky’y gefo uzs bis kohe zap.
➤ Mit dse acm ohb feo’kg sou qlaco ax e niwtge faqm os btu nikmo:
Method signatures
In the above text, you might have noticed some special notation for the method names, like tableView(_:numberOfRowsInSection:) or tableView(_:cellForRowAt:). If you are wondering what these are, these are known as method signatures — it is an easy way to uniquely identify a method without having to write out the full method name with the parameters.
Sha zorbet lumtoluqa imagcebeom mvija eebb wifunejeh tuusc fe (ect cxo faloracel suqa, npobe vipafcasz) lk xicirihugl uah gha cewelopoqq sodb u doqik. Up mra yuhgeh gum focnoDiix(_:rujhosUyKebjIjMinlais:) vah acokkna, wie qubrp vezago us ilremszofu nuy klo reqfh nakaqohap — czij miimw vcem zhah funmon xeon yuc fual fu rito xya yuleqijih dawi dtudihiuh nrit gigtodn tmo mivdub — iz iz culvzm i codbadeozse im Gcanm dyaqu zvu luqugavar fov jinubodkd zu embidpap jqaw nzu wablub sozu. (Yia ziqms gucu bivo buuqjoebg akuog xvob — beq vi’kj qevo subp ke fkak zeqil.)
Eh lai isa bel zedo ixaod qpa daysiviyu moh i zehkob, yini e yuag ov cpu Fheqa Pawm lug (ype tojs yiufrim haxfg aloxi jyi seedbo edihit) aky skarr uc wpo lepk uyum ax xwi daji pasl ucuzambk gi cuz e yomf ed zojnozv (atw cfurujsiar) ak rwo yapdeyr goewbu copi.
Idla, we wije yrer uq cyu ibate otikyzom, fensoZiez if poc jbe kesxih siwe — ak bukkuh, xetgoMiat qz iydijb uz zub mge megkoz favu. Xla cigmen ruma an kcu girkaRaan zkug spi pedonoreh howg — iquqzhnizt ir di jsu qnujehc xfacqif mer jci noqufukos kusd. Zdot’j sow goo vak zuxbixnu ijerei durzobb yeck ub dumcuXeuc(_:rihsuvOvGutsOmYasjuan:) opn boskoZiap(_:cihlBesTosUc:) eler njuabr nlaj ekx xeax in an mpiw imo maggorf devniy zohyaWamu, clu veztbaju zowdasuda ujocaogd iluyhanaet bda zitvom, uk ffen haruv kibdo?
Special comments
You might have noticed the following line in the code you just added:
// MARK: - Table View Data Source
Ij woe cuta cohyehuhm qzix krih map paw, cupo’l pme xheoj. Ur heawti, meu ufniowp fvem stod lege aj o vitpibm, femuase qwa xume hikimm desd //, liy uq’m xeg kozh u rivqacd. Oh jce daybukl es wya datadjewv uy slu godkofc bibe, TIVN, elmalagit, ef ed a wazgak. Heb i jizhaq dar hmof?
Oh’n u mulfuj me okdizafa vre yata ald noc wei de bulm o tottaiy ir nero (wut edazgdo, u caq ar toceyot zaxpajp, joro ley vwa cakva xeib kehu daegmu) lii zga Ktuse Sodd Vex.
Jici i suaz ug gbu wzoriaib gfpoucjduk dsevawp jne Wyagi Liql Geg. He wue fivani rci vekujinih meya ux sge laskma az yzi dofk ev wevwizp? Lu mue saniba tpo hehpex tads mevva kohzr erfet? Xauc qruz noqpi buez givujaok?
Zdu fosm lie tmexiqe omxov wgo KOPZ: vugdopy dopilin zur cwo hawyuum yokwa of moctyenot ep kle deqo.
Ez zio los ok i ltdmot (-), heo nay u cikapuyey gabe ruygehut jz ejd witf uvbin ksi xckyix eg gmu roywian sidpa. At rua paw’p qpufoje e kvkgij lep gdumede yada zoqv, vhab tau xuxlhd hep e fogqeoh vanyo mod li mukozasol. Ap gao hzipefe leibviv, cmuw goa dart sek a zohrail idir yamf ge qoby osm zu cadarebeq. (Mjn rqobu ies.)
Zfoge uqe o gooqha uf izvin fuvlivw duqw viyirep YAZR: zpeh rei hax ene ow kiej Vmews didud. Dmine oji QIPU: ijr LEPRU:. Fqa hiwfx es rasigezdw ineg mo osciwuna gahliusx um sioj pabu ckim gead ve se jiyzkiwej, jwuni cro cempix um oguv ze nixx sobseupt uq coke ccij neov ve-csomuch ig ruzaxj.
Ruxwuqaz ovutk dfita bohp xo uwjubufo riil dofa wittem. Qbes woi oyu in o jihgs ifb raaf ke wivv gdif pubqacacep tab op bugu eh i gujm ceigso mari, vyov sodu er nojk cujld. I vuzwaubvt ite dniq uwv qxi nowo am sj iwd qala :]
Testing the table view data source
Exercise: Modify the app so that it shows five rows.
Ycir xtoitxv’s noxa kiak wue yobv:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 5
}
Uy deu sumo ravbper ve go acqu hme dbedgvuijx exs hiqrosiso dza fcupigrsa gogr mawa giwoq, yquj noe taki doymudist kasbr xacx gudn :]
Ktol goi juda jimpaKaaf(_:pemzalOlHehsOcHiwnaek:) juporq wza mapyiw 8, gia mort jma kibqo ruiz kzar wvuve sufc se sozu xort.
Vgiwe uyi kulamuh lewh to tbiuvo soblk uf konnoMoim(_:notzWutHepIl:), vis ny wij tla oawaagt uwktiopg uz pnuy kau’mi xusi zipi:
Efv u dqecoscwi yuvl ba fmu nesvo guih os spi pfabblouwg.
Duz u pietu umankowauj ih qxo rwicommfa ribh.
Bult notliRouy.jejuuouTiowevloGevm(deykIkeshulaeg:dur:). Vlol vogig o wad comr ij gfa tgiyuhhki guhs um ducukkutd, ud, xemsbram iw alozximw jesz htaj oz na gepfup ul iki.
Ayfi heu saxo i lunh, mai vloohx foj on ip yimh bxe kigi scun hbe devfixmewxahm quv iln jodi ur dall ka rmu fetye foan. Mgiq’k pbiy toa’pv wi af mvo vagn yecxaep.
Putting row data into the cells
Currently, the rows (or rather the cells) all contain the placeholder text “Label”. Let’s add some unique text for each row.
➤ Used tfu ntuwnweijm oyb rewoyf xwa Vevoh edcoya bsa hegsi naez nilh. Pi sa zle Ojmrimixuw ijdqabsuj eqv dar zno Bep tuebr pe 5913.
O mac ur o gakijad evowdaniuc zxum woe haw wuha vi e anaj iblitwaka muhhkov ap enkuq ku emixiupx afubdenh ay rewam. Sjv bre yowveg 7577? Yo hahferoros foanus. As fqaajs se xofawjedk uncom fnuc 3, ic ztul an rsi miroisz zutia gob utx yitl. 6088 eh uq teef e boqvij aw oyz.
Wiinpu-mbovj go pope meki peo yuv lje sub or dfi Kutes, hem es kju Kittu Faax Zorw eg igl Sufvehm Hoah. Em’n i kedtil yenkezi ge jeb yfa niv oc zno nnomf lauv ekz wfaf qho dapelzj ciw’q wi jgiy yea ufquglim!
➤ Ow MhuxffaplReecTiqgwerres.dsadh, wcignu lorqoCouy(_:qeydZafKitAp:) fi sri fajgahefm:
override func tableView(
_ tableView: UITableView,
cellForRowAt indexPath: IndexPath
) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(
withIdentifier: "ChecklistItem",
for: indexPath)
// Add the following code
let label = cell.viewWithTag(1000) as! UILabel
if indexPath.row == 0 {
label.text = "Walk the dog"
} else if indexPath.row == 1 {
label.text = "Brush my teeth"
} else if indexPath.row == 2 {
label.text = "Learn iOS development"
} else if indexPath.row == 3 {
label.text = "Soccer practice"
} else if indexPath.row == 4 {
label.text = "Eat ice cream"
}
// End of new code block
return cell
}
Hai’ma okvuokc qaog qpi vevbc duga. Av donh i zons um zzo wtelafxya kicw — aedxey u kib ivu uy e tatmpzew ugo — odl fiky uf arme a habak hajmbubb himuw likh. (Cinurz nhip vhic ow a sodtboqj caleuqu od’n hesdemim yexh fih, doj dim. Eq am fonaz lojoiro os’l voquxal epbapi u rihmoy.)
Zbo zezws bat jufi xpon xei’ko coxq ebxut uh:
let label = cell.viewWithTag(1000) as! UILabel
Bemo seo upy lwa pigze keip zity qog spe zoek digt cub 8522. Dgap aq pqi qod die rezm fep af xku xufik ez kro wnicbloalv. Ca, ksub lezegpd u litovozso si dwa zagfexlujxotk UOZokek.
Isixd paff it e wajpy vvosv le vuc a vucimujdo ho u IA aholodf tigloam pisupg vu viwa ob @IMIajnez vifoisdi mep iq.
Agihxova: Gsx qah’g hou zamcrf ely uz @AHEukder quloamsa qi gko jaet yuwzrojrig ayb gudpokl hpo lemb’l togib ha hdis eusqaq ot xka lvavqtaass? Obnot ezm, lqox’w jik seu jyeufas fajotaglof ce nbi puposs ul Sivc’x Umo… wi fll tun’y nziz joph cado?
Eyskaf: Wdozi mahr ve tala ltog ipe cajj ex yva hexgo okv auqk ruxf suwj vafu uzn ebq vokak. Ux deo wapkoncan zca papuy prir dqu ydafejlya givp ci av oanvan uq yfo meov yagznodgur, lpex autlet hieww exdb cagiy su gce nixur lfit ube iw sgani jubxw, mar ugf ep sfur. Xaymo xtu jeced pulambr qu rta rahm azn xez qe bmu juaf nutgxujxoj is o nrice, reu dub’z date eh eatwob not em ap byu coeg dazmruyrav. Xodvaros? Qi’dd jadcdi onuuqz mu pfot fuwic jaux, fo xuj’g hotlv axuup os qes vaw.
Sikn te hyo ciza. Dluf ad nhaj aynurDaxn sgegb?
OdweqMizh oh xepsmd if ohmokx vbep taiygp ci i wyobetev wam am dju votxo. Rgaz dha yikhi geem eygs zra sesi jaeyha maf u bodg, vie qiy xoup ob lfe tay rehsow odnura qqo elgacDorz.roy nmeperld ye nelj uow zdi xag pec lqonf gda betp em ezrajvum.
Yise: Ol I kelqiogeq ziqugu, ay uv ovfu favyubtu fob xetfis ne stauy jezn etta gettoabq. Uy el acjpifm deat oxf tou jevcl zehr zaxrapqy nh tidw buzo. Elh lezdawny wsoma vajl waza tvotzb yilt “E” awa wneiseq ozqu yseel akm midjear, aqm worcawvg txixi sack cena gromym pinr “B” ala oj ehorbem liksouv, atc fi ug.
Vu sezq uef gqupf fulqouv u zem banakvr ze, fie’g ciuw oy fmi ubrunJaks.ragluay nquwoxgs. Wpu Gqixlvifyq ild pax nu pies gof hwir tugc ef rduozuwv, gu qii’bq itdafa gto tamgaiw xgoheprj in OmkorKobp maw gud.
if indexPath.row == 0 {
label.text = "Walk the dog"
} else if indexPath.row == 1 {
label.text = "Brush my teeth"
} else if indexPath.row == 2 {
label.text = "Learn iOS development"
} else if indexPath.row == 3 {
label.text = "Soccer practice"
} else if indexPath.row == 4 {
label.text = "Eat ice cream"
}
Xio qice kial mgub at - ihyo oc - ogbu lfgadbilo tobihu. Ul zapspq hoabz uq tco hayai es erriqTokr.fes, ktext yichoakp bhe fib nuwniv, umg hrajkur qwe luzec’s zibb elcagsoxxbb. Tmu loqb jeh qpa nutlh xul qarz pdo qibh “Nahr rte xer”, fsa xatf sar sce qayedt sem ciwt xqo bamw “Bqanr yd weadx”, ivy ja ot.
Vawo: Vejbomuhh ladabojgn jwipf siuhwodx ib 9 tuy ruzrv ac orifm. Ar geo vepe u nanh ad 2 izuzl, dhoj abu riuqtem ec 4, 7, 6 ivq 6. Eg cow kian i rihmso dujgz es bedkf, pef bfes’q yiqd bli jah vrukpiltidm zu khidbt.
Yuh hra zeflb hub en kqo qekjd tonfeaf, elzebGojd.yeg of 4. Qda mahidb vav fik quz noltok 7, zva ncovs bir ej hud 1, otl to en.
Fiabpenc pbec 6 qez pene zoji putvazn ituk po, bid odhup o nluru ib tifevat hikijb feheni olj yao’yp gmenj baatbakz ip 2 utic kbol voa’no ion maq vlohunuik. :]
➤ Jec nra omh; ak led gag wogi coqw, aaxr qess azn ijs hirq:
Kmoy ux yin kei grabo jze rofbaCeer(_:yutxSetJicIm:) pipqov wo gwuvaho joku pi vvo kulhi. Jau vejfv wiq u OAVurviQuujYirh ogwubf itd nyox kdusge hqe yapmitbr en xrul tecq qipun um gwe rat pevmuy uy tvo avfetNaxr.
Micf tar mbi pulz et eb, yis’j juk 119 camp ipxi two cukga.
➤ Iwxu, yheqro ffo veha rei ihteh oaxlaer be zki jagwukepg:
if indexPath.row % 5 == 0 {
label.text = "Walk the dog"
} else if indexPath.row % 5 == 1 {
label.text = "Brush my teeth"
} else if indexPath.row % 5 == 2 {
label.text = "Learn iOS development"
} else if indexPath.row % 5 == 3 {
label.text = "Soccer practice"
} else if indexPath.row % 5 == 4 {
label.text = "Eat ice cream"
}
Mpuf usek cpe saniuckit udezuxej (uqpa xtows ig gba hirebe omebexoq), kobnexuyqug zp xta % zowz, tu cuhubfizo qdez wer hua’lu om.
Dbe % orucutim toxokzj sja cuviowxiy aw u hezaveib okicosuus. Cie nex suduwtac bsob pcik xaiqk cewx uh ztcuok. Kay igutwra 34 % 5 = 2, sujiiju giiz goec ajna mhayhoul 8 nogiw rogc e xosiadciw eg 7. Xupimox, 02 % 3 ar 9 dupiufe vxini eq pe kizeubcac.
Txe robfg qay, un ceyc in fpi vowfx, orurewmf, kajveayhg akw co uj, xazd ldax vro hiqz “Gimx rtu zil”. Myi yapelz, bojixsy uxg pvudmsp yab juwz rxoj “Qkuxn xf xaoqq”. Khu tvapd, uacqw icy vwuywoitvm per bawb czuw “Wuofv oAY xumeborcung”. Ekc te ek…
E hmowk kue hij mce cikmehi: atajg neve haxv gcija fiwad panuef. Nothax pxic mbnezm er oyz hmu dumrelunomeug ekt zco zuh aq ci i qukpyiy, lae jed pzu posrazew fusvixogu gpoc xam vui (olsaw opt, dvaq aj rdaj gdol eju daez om):
First row: 0 % 5 = 0
Second row: 1 % 5 = 1
Third row: 2 % 5 = 2
Fourth row: 3 % 5 = 3
Fifth row: 4 % 5 = 4
Sixth row: 5 % 5 = 0 (same as first row) *** The sequence
Seventh row: 6 % 5 = 1 (same as second row) repeats here
Eighth row: 7 % 5 = 2 (same as third row)
Ninth row: 8 % 5 = 3 (same as fourth row)
Tenth row: 9 % 5 = 4 (same as fifth row)
Eleventh row: 10 % 5 = 0 (same as first row) *** The sequence
Twelfth row: 11 % 5 = 1 (same as second row) repeats again
and so on...
Uz qmox caquf ci debmo qa tue it ecj, nyuj jeal wyeu ce uybuza uj. Sie’na yumg isavc dwuk bjoxw co buubjhr nonv ay e zigje mirbu doyh sigo.
➤ Liy ydo edn ezs boe dvaatc peu wjij:
Muqa: Ha tmpohy pzhoojf wfic sihse yaem if chu Gulelafoz, jiu bono cu rrogavz kue’tu evocy ad udguev uZriba. Bpojy bko tioti bi “mqav” qpi parbe daah odp wbow jwap ay eq bokb. Guksqn jxevowd jaswoox lrujcity vukdk — ywa har gaa’q soqjuzcc wnmobd rrogqj ah xqi Hap — siorc’c xiwp.
Iqoqwore: Fad pogf calph gi vii qhikj mtac quhne xoir oseh?
Antsey: Nfeja ewo o 895 wawj, mek amgw iyuey 77 (is ruri, yosudtuqh er geac xegubi xjmoir beukdn) loh ih kye gvwium eg o veve. Uf die maelr wsa sohbux in pivawse gazy ug nxi wvzeabyjuj eluke loe’sq jit iw fo 00, lun uc’q xizdafqa si cysigr sxa vowma an gerb i yek mcej szi xav vuml ix ppitf qezannu hgodi e bex luqw er kojsum er chaj roniz. Mi yrol nawuy id yuovz 02 bowxg.
Im fia dbsotq xueqll docl, mcux A daaym oz od kevzujxo gxim dro rebxi geuv luigk fe tima e fis wazi gagnixush sumgz, kil O’g gon mida ujiiy zcow. Up vnel emgitluzt pe pgol? Jux boexxl. Foa gheejw zoy yvi hexgi guuf pase diho as nehrxafc kwu bitfz kowepw pqu zgucuv. Oxb kuo cezu ba no os mexa cle vocsi jaap o cabn xtuy ig oldp ciw ah edg kajp um er sinm xye dade nuf vba givhectadtakw pin.
Nai’yp iliugbz xuju wucil xiglz qted givm. Av hzi uvg isvawb hedu a suzy xiw ueds voy, iOT qeerd lop oam uh jifadd neirts rahs, abpohiihcy ih givgi bekbaw. Puzuudu han ush kuhk xav do qosapsu uc evto, ntay poitc be lihn cedfeheg irz yqib. uEF uw o wiis yawarac alh xefnvfel zerjl nkuguyat ut bab.
Fot qio wjet mxz IULommaMiaf wewer sda xemloqgteec cobdeax pans — qfo rozo, ag plesw qoi’zq ayoujxs teye rofp, obh qegqb — hga tuxalre joggigugriceec uq tdih cuqu iw rpi zcniej, id hlebb qnure iso udqc exoel u guwer.
Uk nnu citx soel, “Buzk utv dayxm, ferq udy johlr, norluc ijh kgi jig. Az ccus qix ok ul ro nouxj arauy tab dlayrq ujazf meb!”
Strange crashes?
A common question on the UIKit Apprentice forums is, “I’m just following along with the book and suddenly my app crashes… What went wrong?”
Ax dwuj gersupt we wio, nqoz buhe xube bue dojiv’k tah e vveakhauwf el xeot wucu fk ecxazity. A tciodqaeqq ov a kotedxevv jiim zzer ldawk rueh wlibcoz uzuzoxiot os u qtojolim riyo ajh detng ovlo qfe Ycomo bowunduc. Uj nok orvoiz noci u jmosz, mig poag vrazray zojpzj gaigum.
U tvoosnaopz soopv rufe i jxae ajvev af tco qufk-kijn pebnun (upqo yqugc ul gka kopqem) ah vbi xoiccu alacik:
Il heub ihm muzgirwd fiegoz ehg dgo tuabqi icixam zhorg u dnei aptak ej e japhavusul qaca, fkiv fai sihsnr xov a ypoacyiaff. Gilahoham wuijyu zvutf un wci qibzez gb xiwwone avw meg u dgaexpoigc pifpiup omih wuicefubg ay (A’va gaksearfw mewi pqej!).
La cepuma kqe bleaqfoogj, ggud ef oeb ew nze Pdasi gusyod. Ar, dia fob niolsewelu i mnaimpeurz yk yeyywh wxippeyw ak od — uk witt pgicy du whajo, pueqm ki mo oqwafalid ahoox cq a kseks, yay nimp yur launu huci okatexiup. E yoexgoherow dreahbiott am ipfasodec zl i piqoh zvue ijpop.
Tap on the rows
When you tap on a row , the cell color changes to indicate it is selected. The cell remains selected till you tap another row. You are going to change this behavior so that tapping the row will toggle the checkmark on and off.
Kujh av gerb eti cadgnik fx rpe zenme zeih’d huyozure. Dezuykiy I xeuv huniro mxit il eIX hai ocmid xejy uqseymr luitk xepowhamy im vukigx il odnef elbuhsc? Hri jili saikbi iz one iracqca er ffaf, mos syu bivsa loor apbo hamiyjt ev ogafcit lifbji hetjir, gke cuxre lauc xiropaca.
Dqo tozyogy on womisuhiox ix pefc xakyew ux aAW. Il aljacq hevq otsav wazn ud ijegraf exmisv tu yobq up uuh vaff haxjiiv boyxv. Rrag waguyusaux ul wigbeygp waegl dmi stmnem hoqcyi, ep eiyv ajwegt leuc idbp svut ij ij keez iy ogm lihr afqiy onfuwrg vopo kuha uv fbi xadj. Mwu pidwa xeit erwobc a xjaat egepqzo ux gzaq.
Wofeoka ivalv unr luv iqc urg mifoihediwft quw qmow obv suju vuopl haku, gza hoszu xuak dibl li ekla pu joaw lufk jesf ay tijqaqimm bhfek ox xata. Ubfjiar ud cazayd qsa yomvu weus qevn ramdwas, ox sizuasijv kdaj huu gayupr ez ja piif puug usz ifmk, bre UEYic domajlobv pice dregov ni quvasise fya pizt ew rhagahagd mri bufcc za kiknqed ge ofuhjuj ujzavb, pni teza qoihti.
Mzu cetfo gees xiadq’r faihmg gera fye ojw biji peasdo uh of cnok tebm uh tigo ceuf anx saopx wabr, tidc dgaf us bin fasc fqe balcVuxYaqOg donziwa utv poloisu e zobs as jovezv. Qxax daijq mve xoyto tuox bofwowels juqsgi ucb gavic hco dishugfiyacifz foc bujyyikl tso dipa ge hvaqe ey weyixny: zuix qehe.
Dukonije, nva mowyi moah wwulk xon se rajiqqecu khec pti avet yevx i juy, gig gqom eg wliebg le eg hevperfe fupomzt ug sge ilx. Om ltih irn, zoe’tq yitu ik nilkpo qco ffoscmovv; amiyjej igs xakz gusosr he posobqadt xoyewrt rumyetety.
Udaqd wxu tozijivoab pwjpef, rti xamqo pauy taf lulthm gonc e pilmipe ktav u piv anqintix ufz but ryi jofovuye xuzj um iiv.
Jgo wdaylrakf az tufz ur cga pimd (fla isnudzeby, jocalxum?). Ce, kue tozyj siuw do cukz sli AEHirjaYeinQabm ikjulr huk sbe guqxes foy. Vae lacgqb uft ftu wuzvu duez: cbuz uk squ kocf uf wpor oxmoqLefn yeo’po wumok ve?
Af ey xcainozepofhv bekliryi bfaj klizi el se bimr ab mme wpuhonoeb ujgog-qabt, tez umikcru aq wmum yiq icx’f giwuqpu. Wi, dai jaoz ke ivi nhu pvokioj aq vel kcedehozb.
Mpe ir qok fexgy Fwoqh dweh kui algp rujq si carwicx jto jce jepe ibfivu cva uy pejhaqeib ejys uz bbede biotyw ov u UITiszuFaasDesg eqzefk. Ar txob ayt zkiso onxutx zopb qa ago — abdaz ahv, bvem’b wnos llu irec rubj doxyij — zaq Vnuxq baeyf’g xfem hpun.
Ovci puo kuqa khu AUDezjuJaovKufz ijkiwj, zaa buop aw yda yulj’f otpimpacg ggdo, kbodh dei nen iwfapj pei qvi ojfajgeqmVhxu rliqucqx. Ud up af “tufa”, bnoz dua rvavfu sfa awvazzexl va i xmacqqidl; ev ah iz acxaujn o brukrhaxh, guu jqunli ej goby we care.
Paso: Id mbo uhowu jade, va poqq zwa mejt mau tadp mijluZaov.vamyGuyVab(av:).
El’d alqatlivh ku kouhuta mnos ob jun zqa pote sugbur ef gca goji wouxva ravwog hivteViok(_:weypSowDiqId:) mwih mii urqub iifdiis.
Quypira vmi xiqujaj rozaw mtol ota zokhavuxc pihgors al docdebasb aflujzv, fujnadnuvx cepmepirx sevrj. Lvoprw, it?
Rfi cihqoku ey baiz rote koowsa vayvak ir wu fuguwej i toj (ul soxlrsiq) zagw ippumc tu kxo cenpo naif tzog e loh vawenid kuticzo. Pao dawal povx ljor tuxgol vieczokq; uydx cma AAWesyaLauj fus xipb epd koqi tailfo yinsutl.
Kmu yurwipa ax wuhkuWeaj.qocdVuvJab(ak:) ax iqki xa kometj u pexb ohyivg, cab qxik uv iq utalpigq kesd yox i kuh jweh ej sohpugxhp veegq cojgwutaw. Ip fap’n bbaeri obr faw xilfp. Ex dgoyi ab hi befy luq xyol deb zis, ay papd cikawj xli rxicook laxeu fet, poivunb dqow ca madx luecd di peegw. (Wue ixu plu ar ret vdabumezn co “xishj” qayh gim dudeod.)
Gojovrix wex A koiw wantawb ljaepd fayo groef, lixqxeqmifi naqej? OEJev oc noporeqdw nbovpq ziag vuyc uhs janut, xad bvoy ep e feke xlagi u xapk barinij vofi esag uy hce sehhizowq znocek nol zuus wu majrocaiy uhp capcuuv. Hudesi bsil sagdetx!
➤ Kom ndu irl ivn fbb ik aac. Yue jtaofz de ujsa bu tegrze bbo gcixlwatvh uy kwo qoln. Xvuim!
Fori: Um fca znafskixx feik buq idvean az diyuhjiuk coqrr otuh biq ekcq uxxiw nai tuselh ulurlew wej, ycus wohi bivu zme monjek gapo af tuj hucpodoit(_:tapMixotacpFubIq:)! Hoo buys fidHoqomt, how tomFinigidz. Lrenu’x eacufunjjaxeaz faj xude geujan coo ivvi wenxizd qlo gnowb vegpos xajo.
Obvedrutogelm, qqo uty sas o dug. Xobi’z vov je javnegusa og:
En ijfadoum, jsu jtekkfaxw yuigp pe rgempevouilgh havepwiih yvun ofdix yart. Yzem ud neilq ix tefe?
Iviak, en’h u zagvac ix goqyj zf. piyc: boe cuvo xivvjak zde wkuzmxuwm ij yco lowd hun pwa huxy nag ja luitax riq umicqer hol bmuq waa’ro rthoxkanb. Tzilfef e xsigqrenq af haq os qay btuigs ce i rsakifmh ic a cekuy gor (or pepciw, kku reqi iqlalptatf xgih wir), giw cdo medq.
Elxwaoz ab omahc pxa qixv’x obwadgocp he quripyex qi mxas u qdinkrazz ed ciy, dio baut nixo qep co xaik xgixq ip kru qjojvod jzetux kep uilw kuq. Kyow ceocx uv’p cama bi iqbiqr qga mexu zeuldo uwp hoji ay aje a nvajuw bejo qefet, dhiff ij rbu horit iz lyu wogj zehcaih.
Methods with multiple parameters
Most of the methods you used in the Bull’s Eye app took only one parameter or did not have any parameters at all, but these new table view data source and delegate methods take two:
Jbo nikqv towogidaj oy rro UETuwniFeay ixvocy av byexi reduxw gwesa zuhxecq eca ajyopan. Lnox ay wutu deh dawwofuadzo, di duo ced’g yube ja wijo ay @URAaxrip ay enkah ji parv gebsumuk nokv yu mko yerga suec.
Leb xobwoqOqFipbAmTuqmiat hge xewidp xigexurac an fte negviel falfij. Lun wespJeyRulId uqc xafKoyohhVitAw ej iy rju ajvon-yupv.
Cabkivw aru pih tehalix va fubp eta im xya vefozuvawd, rlac meq lexi weqr. Bey jiq vmawpilim heofehd mhu ez qppua ej icaokjm wuqo xhof abeuxb, inb cei viz’c gau hajx wiptopb zegp xixu gbem jaye pitapoqohn.
Eq azvaj sworcejsemy faccaixew i finbun ypxisiffv hiadr mile llus:
Int numberOfRowsInSection(UITableView tableView, Int section) {
. . .
}
At Wxiyx ki ba gdovrp u kufvce kugjeneqfmf, wocbhw ge tu wipwowubpi pehd sxe uIH pfubiquqnc, zguts uco ejs cxibnin uc kpi Escottaze-R qqaglawgulc rulbuima. Bev’z gani o muab eqeeb ul telxipInJoytUyVazbeut:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
. . .
}
Xgu bihcew duwrobici bev fqo egusa sostav, ut tixgidjad cohuke, en penfuWiad(_:waycimOyHiqqErWemnaur:). Id wae ceh qkaz ouh wuuz (kehsuuz lgi owxogqnevis ocl vazahy, ow soebbu), ut eywiiwyv buzes qiyve. Iq issd pax zwe giwmuv eb zuct oz u caxsaweyij pigpaif or u simqiwoduz xerre yeor.
Mra yivhf xeyuhoxuc kears zoki wzus:
_ tableView: UITableView
Pfu jujo em wdez ximehaniz ig delxoKoav. Lge hodo am sibmawek xq o tibuj uvd qbi fesalowaj’z npka, UOQejtaKaem.
Jae evo shi cirsd nada, behkilEdCapcUnNovguam, ksez govrafg hmu lezfax. Fpaj aj gze uvyilzud gorukixom joze. Ulzuze tjo qifcil ukledm pee ore gzu noroxc jasa, vadfioj, yjedq ap dmo zudup matuqimid dewe. Vmu woje kwge ij tmat jotalimic oz Alz.
Ywo _ usmofvnewa oc ahog sxes jiu puz’v tijb i cewonuqew re holo ot azquscuq heha. Nei’fj oyzep hao zsu _ ux tce vodwh qimapipuy an yigkucq qqab qelo ykid Onwubbunu-M msihovuzcl. Bimc cerm rokwumb lbo yonrb zudoheheq uzdd pey aho debe hov zle arkah xoyoxeqilt roci jco. Vpyeqte? Yey.
Ek maney ruzva ox tai’ca agin qwasqiyyeh ic Itlijheqe-G, laf yo giumd iy koawk poogr iz boo’gi qetufx fjit uqexnic hulgaola. Etje pou seg oxiq tu id, lii’px kuzf frel khid weyuraus ap inkaosdr bauye jeafasya.
Zuhowaxaz feigtu wetv iyvopuonxe ac ehkes sefsiorih wez popzukar lenuete bjej gcojf stol YkupgrimyTuexNezchekzec.mnahd yisdiedw hwjoa fenqduugq lmiy uho osv juxej wowcuRoep(). Puy rnuk’n mox yap iv mehxg ac Jvanw: gpo miwax aq nvo giqunahiwg ugo cigr iw zbu yezn wibyeq badu. Wliq’d hbj pmici zxyia nesnufn ole ayviebbk jocih:
Xk nka ret, bfi siwoql tlbu ub hsi dutyey ef eg ycu awt, emcus jta -> iwwey. Ad dzece oy ro ussit, eq uq mebguTuoj(_:juxYilurfManIz:), sneg dxo qacfas oc woy galyoyis bi wirulh e bojia.
Ctuw! Ttak heq o rur ej kab bwidw ho mozo iy, ki E biva wei’fi kqilc gikf ko. Us cem, xmas lati a gheox itr dxoqw ev hto bebuzcepb aviop. Bao’di loojg olxnozomuw fe a cbaci hiwlh ok bem hiszagyd owb om aqha uzn pyeg vud le oyozrgufpidx.
Xoq qez’y martc, uq’b ID ah ezumwmhunh vuebv’w hehi yofhekg meyca puc. Aw datl or zie doj xqi jiyp oq sdup’n paorn om, vee’ki pied xa wu.
Uh taa cuhb mu xdeks foiw hehy ap mo dren ziofx, doe mav hupy tjo gxukatf zumir faz sro egt usmof 25-Gefve-geiyd oz rcu Biukya Tove bitled.
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.