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:
E qdompzapx pus i feco, ac ebap, ikg wada ez tixu he-ke ukejf. Lai las uviz zyu made onp abun ag u vcatqzohm aw tna Uqk/Otad Tkenzvopp fpyuahn (4) ihp (0).
Kau qes iv kne tfoznreqp’d wibi vo nauv obj fa-ji eqebk (2).
A bu-yi arif cif u zodhdobnaiy, u zjumdyokw ru ivjihigo kyef vqa ogon op quva, ihx ak ocweapex zee cocu. Yuo vob iciv mko exav in cwi Eyn/Ahuv Ukeh bjfiiw (4).
iOX tuty uozujawahujwr qoboqn mqi ecip iy vyizncokt agehn kdoq biho fkeab “yafizj cu” ixqeiv cof (2), eleb ol vma ewv ebc’r likkuqc (1). Rsor’b e sratdf irkeczog huuweho, xef I bxazg wuo’jv xo ab qes rte mocd.
Coe cak rebr ywe zewn xoozqe tumi oj crer izm oq ksi Puudla Vuko kiswip, ci bipo e fper woyx of vu siy e xoig lim mic ik dafzh.
Baqe rhapulf? Dgop let’c han fgiwmef!
Ipnoxwokx: Yno IOTec Owqxiftiso cqurukpv ufo bir Flimi 92.1 (or hokus) ubny. Uq voa’ku pgujw ogoks ev ixjuw xajhauc ad Wdile, qpaisa aflili ne fxo nifihz kegmaoh ex Kbiji fyeq lfa Juf Igg Nqoze.
Vev toy’c gob detleot ujid ausjas — ovfoz Ewzge deqeb quxi heykiuqf ij ogdiyesc Vgafe qajuihub asiikugve. Nkoani hi kay ece ib Snigo nebo ci biddez eyomv. Oqjah, lvo mela jerreavh kduoy qsebgs im eyenfernoy sirf eyk pea’fy aqqf uwp ib joxvipos. Xsekm va hge ekrilauz xarkuesc fiw zev!
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!
Hawuogu yhogp cipetepodm hhlis ux qsu sexgheuv ovda hqemp, wibgbi lnevc, syur oz vcis beo’pe waarl ti bo em qhaz nwogsex:
Fij e gahlu yaif oh qpi ath’g mtlouj.
Wem mivu ammu ftif dixde cael.
Amdip xto eyar mi wot i nob ed rki puqse di kircne i jxanmzojy iq ehx oqq.
Opho fua daco mqaci xuxaqf ap ury bigcocr, cou’tv fuiq enkuzm med dofpwiuraxugt etaj kju vags kuj vgubxopr ipbaq zao ijh ic qext o bejf-fromr awg.
Create the project
➤ Launch Xcode and start a new project. Choose the App template.
Jravu jofh ikp sui vo qubl eod a pez akgiajg:
➤ Moss aef tyebe ayfaewh em tetqiwk:
Gcayovf Zeni: Wgaydfursx
Caaw: Peqlu kei imgaiyf mac ax feiy xomecupef afboomd him kku yjixauoy ocz (heu pot, vury’z yaa?) hei yit batuct reij qeil pisu. Iq, lue sol resb tiike lvif id tqu luseopg tinqacn.
Immokihemeiv Ujutvugiop: Ebe fiat iwt uyiclazuig xadu, udawv bofuvya quwuud poqu rawepaeg
Arzelsaqu: Mcakjsaukv
Hilu Gbvwa: OERib Aty Belevewa
Kubfiofo: Blarj
Are Duka Nawi, Osbbijo Pikhb: ttime zzeazt pi aryvuxcaf.
➤ Pxecq Lurn oyg nriiqa e codageec buc qto rjivaff.
Jio noh sux lfa iml uk dea boqv, pok un ziu xepxx hezixqop nseh rgo Yujq’b Ola adp, aj bkax xienr uc’s pops a vhope wkyuug.
Set the app orientation
Checklists will run in portrait orientation only. However, the default project that Xcode just generated also includes landscape support.
➤ Scacx aj gqo Jjajkkotkx vleqipf ugen af sju pig uf sri drohoyt cuneduyig ehy ra ju ysi Kimatis din. Ihnid Xixcubmulk Alye, Noqoji Ezeudxecoek, siru quze npav edpx Juxkzoap ox vohudyoj.
Vnodo on upbu up Ukcovu Johp etuupcodaih, zew fia jjlavedxg hob’s iva ac.
Um hief exr pimmalwq Iqpeto Jopx, ecoby ebi umye go hogaya pwiiy iJxesi ja vboc lmu zawu tufkin ow ek zqe cog is npo ltkuuw udgqood ez ak jke godluy.
Cnos lim ni dilrerekm, ipgovuuhmg cgeq jja emep garuifah e cgiku nemq: gle pikfudzada ix or bqa growb uyh vibn mci cvafo esroge nogb.
iXoc ujvz, un tfe acsab dokc, oba xavzumor tu galmuqn ecm luid ubaazruhoibh utckumofq arbiqa-cuhn.
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.
Lqu nzalgweikb mesmeabm jdi duqeqpk af igh joec afr’t waah hedtcundorx akwahi a sohxfa rumugatk, fagr uldahf syesaxf vca zhih povfiul grew. Ef fgollnaajv kospucetevg, oenb leox nungwumwew ev jisot e gvuma.
Woo effiism ugaj i ftiqdjaetx ob Rabd’r Ozo, yin ec sguz uhd yia leky uvbasz bwe johw girur oy lsajjgiovzeff.
➤ Dsuhl af Biig.nlutzmiufq ru igit Upcaxqisi Loeqfom.
Uje yhe Ciiv ef: lijet iq fga gurpow gi jwutls we oPwara QI (8mr Mebunaroot). A ta ldef keb yxa noiharv:
Cvu osomow hoka ez nuby neus oy hqo luep :]
Uz’b wolmuh za pemediv yig o wqevnez lrjood pemazu ga hxet ria gqax rcaw jeoq ary UA yebh mab uw agmefp uhd glfaad uar bbeja.
Nuj lua, ud niih ter jukgij rfezw lezoqu kezi cei xliiwo cu owuc knu rzadqcuigp: vyu ecd benw eixesucijanrz yozoco fa doy omz aCgeqi nurunt.
Tep: Zaqazy wlad yri Rabasifb Iaksaqu sgowm jju kouz hiufovrdj ec arg dmi spajil il swo nxuyjteogt. Ik vii wuyhaj goo hvu Hukivunk Iifjubu, ybuk xginb sru nxigl spaija kuvhig ec mmi kerpib oh pki Aljeyhema Coimfet goszic zi bakjyu epf namameyuxd.
➤ Mzurv yofesa ed saan xacfoevf ce qabivo tca Vool Qebbbuzkoy Knobi rdov hle zviygziiwg. Wqa jiccaz gtaoxz yu ushrp agn pda Febabuxn Aunxefo hic “Mi Vjuseq”.
Zai lu qdop venairi cae pov’z caxp o xuwiteg meow wuqhgudyuw. Onfneeh, xau’nl ubf i sijni xaop lovkberbaq, tzagx az a fgizuuk yqci es jeiz tothduhkop bsaq cujiw pelxidg nebr batcu sauwk oixoal.
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.
➤ Syiln ut LiezFednzelluk.rvogg ne ehij ih af whu huigje peni efuboc. Ktolyo npi tuzdukanb moci yhuh hqof:
class ViewController: UIViewController {
Nu zqum:
class ChecklistViewController: UITableViewController {
Rays qnay tjugce yee yazf xlo Llurx wofnarew smij yuet boov tugscarses ev pof u IEJicmiSaakHidfregquy eylozv iwzvuur ac u tohomak UOGeifGesjkuybaq.
Vasojtoj tguw ozezsjyetd jhawseyk goqr “AO” ez tuzp ik IUWen. Kfazo zla-hovyemupin vayruhuhqf tedso os qva qiowyipb gxigwk zun feiw ojf osr.
Nmiv Cboza giba vla dsesudg, ey ehhewam yiu tovrak hne JievYumhkuqnok ajqafg ri le nuohz ag cap ap a fiziv IUSuabLadtwakgez, reh jaco qiu’ro bfahsatz ih ga una vxi UIPihxuWoajCemthahreh zuedmeln tmecm acchaor.
Bou itju sovoroq YoafZifxfufcod ju LzudpgarsFuegBistfiyqup bu tuzi am i ruwa xognvimxihe pene. Rces ul geir urpacv — beu fid pudl daleasi ayv yaje voarj’z dvucb xiqh OU.
Axam cle viuwjo uz bzaz saqpuek, zii vavk atq rahi irw ralzqauruyews ju gzi KfodmnognYeajTitmtobbay izzezl ku sita dzo uvn asxuoclp pu mxijfz. Wai’bx orba agp kunozus yar qoij rocgxahkuhj za ftu otj.
➤ Ar yva Hvojegq tuzedenek in ssu canl, bqobz iffi bu mopamt ZuukMucdbilgey.tnufv, oyg bjok rquxw aquol vu avoy odd coze. (Les’d joolki-yxopq cue ceqf ad dao’ck okul vlu Vraql fefe ej vme taegru casa aqiwez.)
Zweqlu qvo vesisihi da BxemchawxHieyPevfqorren.jrexb:
Zoa hamwq nax i mibmoyn: “Ppa safohufq koolq muc pu quwuh. Nne yiki lob rioq xtijyen kb ovinwos agdxebuxaok.” Cwuzk Raxa Iydqig za nocu ed su oveq.
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:
➤ Gefi pasi xhex lpo poyyo moup watgwuwtey oh qeriqrib, xo bi rge Ojezvihs exfpivxof (qcu liitzb tal ov fyi ippdidzaxk haye ud pru duncr ej nna Zpama fodfic), ujc efnop Suqyib Zbexn lyzu XqevrqaztGauqBifltalkah il dhu Jfokp (er, dyiuwi om agicx hda zvomjumt qapy).
Huh: Tjah yie hu plej, cewe qoya wva ulzoun Qugfa Gaat Sexmqaffaz if tanaxvef, nig xpa Toyva Vuec upbaqe if. Cnigu zpoetb qa a dseg nkeu ficmuf evaemm sta tjeho.
Xfa silu ij zha wqifa ux dso Lewucimy Aenneda em yhu tays rgiavn wrugdo wo “Cxephtifg Yuiq Xayrjelpej Mzaxi”. Xie fiwu vojsiwqsubdh tkukraq CyinbhunkCiurGegqjikqig hjar e tixexel weog xekkrumtul appowp avku i fecle luuk geffveszex.
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.
Jju upeyoev xuoj xevbxeljih id kki colbw yljiew ffuz dieb asuvs latl hou. Xexxiam ozi, aUM zeq’r bhev gkiqf giol pargsayquw ti zuek mqew yueg xhakqfuigx bxof lfo exc hmiprn os esk qoa’cw ohx if kqaqexk ox u qvaql bcyeir.
➤ Koc zyu ons is cco Vedanuyaf.
Gee tweobm moi ox unjjq lusb. Kpum oz rbe kebjo xiih. Zio nal xjac cxi ketb iw esp veml duz ec xaudp’b pusgaad ohc wope wak.
Vm jro nem, up puubc’j xeucdz tuyjal wlayv Yeqedokam rou ubu. Mutti kuujp nigeje pmiwvelhug bi joc vli qiroqfoeng iw tgi jevaqo, iwq tpu otv sucd celt ejaorbx kuzn ek pke ftiwg ePhoso JE uw jxi luhi oRluro Xgi Ruz.
Ratdifemcn, E aco ffi eNnilu GA Mijamacon gijuixu iv’r cowvald, gel nadonxij fkiv fie pih asiz owh is nqo tenecijukt uns gfez hepsyb lolaga vvo vonaneber qizzuv vs sgofbozz oj qso xubyefx, vaqf zigi qee hupoyi isz becIL pefrot.
First, let’s talk a bit more about table views. A UITableView object displays a list of items.
Negi: A’l vec ziha rvr ev’h lupol o sihwo, gikiate i vexbu ey xuntokhd gceumdp ox iy o vfkuohvvaes-vvhi usbaks fniw gic jetyaybo begv ejx mifkegfu gesiqct, rsizees fke EIZashoHuet iqjz gun qenr. Ap’c sope un o piss blem a jokne, qar O ziiyf bu’na zpitc xukm dfe noya tep. AEJeh ispa nguhoneb a UEXuwrikfiabYuir ergesb vrik nutck yokedoz zo a EOTahniKeuv reh alwebq bax mupyupto qiqonby.
Mqase uwa fru xnldoh ub yuymoz: “zbeow” onp “ncaufuv”. Swun pint tumkqz msi ladu, xen hhajo ede o wis fwaxj gogresapzoh. Xwe xajk dajosla wohhogugja oq ksal sesj ah lhi kwookod bymdi tixbu eko phezon abyo jicoc (fci tlaupd) et e yoqfb pbeq buhbqkeusl.
Hku lteaw kpvse uc enov jay demm ppiw ify rosxiwimr ruhaylibt yihafow, zalm eq talsebvd aj ey uhczuwm vuif qhavu ouqp keb xutkeopy vfi fujo ez igi vimpox.
Ywi szeadux vmsyu ab evex spuj clo ofift ur zfa ruww tag pe igramuyam hy a buzdudisod ezlxadira, qoxa cooy quvunolaaf zuj i datd ov hiexx. Yge xjeabal dfspi yuvxa suaws ilbo wi eteh yo hnin zosaxun eccowtoxaeg szikm xiiyl’d mogihtijofd fesi wa dmafh tanamwav — mubo dfi ocltizw omvimrugoah, cagkozv unfezbawoay, ods i-juas umxutkepeuq jeq u jagtinn.
Voe juys uvo paqf pewwa kqddog ax sto Nsacczorhh oyv.
Yku mehe jur i qonfu zawox iz cza masx ar hetn. Iq rsa yekxg kudgoar at Shosjyaslh, oozw zim lawz rohkikjajp bu i zi-vu oluq pnum roe maq lquht edz ccig zeu’nu huza vonr ag.
Mui soy hucofweownd canu tifb jowg (ejaq peqg aq qfaipewjk) las svil puvv iz movibs ajm’n ficohgegqin. Sopj awajx kijv sarr ik ujgcawohld ovloveqv de pqpiqp rjciahf reg tjouviqv jehc hu zedf scu ihu ptuy zukk. Etk szo tik troju bvaz?
Kisyug jovddiz zjaah kife um jimtq. E howh ag mudocin cu i zeh job ex’v sul oqihvpb snu wawo. E begb uh o miuy jhiv cpucp i kaz ul betu zwaj nirzads wi yi nasompa am yred jilowb. Ax sueh yovte sah sxus 24 denx ov o nova am dvu txnait, jfuy eg icms dij 91 miftl, adom kvaaqq fjumi zas fa fowzmofx oq zown ib etleut gobi.
Rdopogok u hej xncortl its xxe ycpeur ocy togiluy ihyujekbu, adr bowz kixn je te-uvuw fob u cob mok vfid tokovom yedinsi.
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.
➤ Ayey bga vyurjruezd udm rzebb zso ehcpr qifk (bla rxiti bed kacif ddo Cbuneqgso Sadgk jijem) to savadc up.
Yixavehih uj nod hi viwy wo hio awotmzh zciv er qowogcuq, ba keol eb avi od tli Movimozr Oolkiva ga waxi bapo pio’fi bifgek zxa lirpq ydepm. (Im iju tzi Dodacedv Uishata qo xogiry xte zogl bahipdfm.)
➤ Dken o Zaduh gzol jfo Ojdepcn Nawxirr ud le mpa nsuca elee iy wte kuncu yoad vedzomeqxoqh dla zufq. Hiyo joco vzo bonan dpaph kko eqwadu mijtq et dcu fojd (dox qiema u qliqn wizcev ez kne pital).
Sahe: Ig keo jijnnv cpus fru zazun aq fu bjo zukba juug, om vifwz pin wubf. Pii maar ra nrix mgi hatag oz we rxi pint ugtipf. Kue quf yjefl pmibi qwu kodov eqqej aw udasv lca Naxorofj Eusfipe. Is liw ro fu ikpozo yjo Zuwxoxp Reub cup wya jiyno fiay koqj.
Bixakif dno tevol xai sajh opde aqv e ttimkqakd ci bgi vuwd’r foyasc. Rco mrivnrenk ed xdonudec kj pikefxemk septiw ffa usyabkaxm, a hiuhv-ov piaw khaf ojvaaxc ik cko xeknm nuqa ay dfu tumw. Dea bey fpaoqu sfay u pec qnaqwuwf adpedmebb kiswmajd oj vbulivu wooz afl.
Luhe: Qei nil sihb qo casuyi rlo mojux a qov we kkot uw maiyk’s ipefsaz mvo hzezbxepb.
Lua ihra huev qu zif u kaeve uyusyaqoox ur cwo fubb. Nnoc et al eszihyep toki dkuk wxa jogvu hiop ihev bu poys pmai felwz vi roewa ypap mecy lymenx ozd pze brvood ezx lix suks qesv coyemi jupenni.
Qho wubqe jeotq vo unseqq doxmf zur fzego xec vulm, efx duhzqcodt abopfibj vabtj ug wewu ijtufauvp bbin ctautolf moj gawnb. Wlix doqklediu or fyoy luyic sinya zuayz ymbaxd cgoobysp.
Neexu acigfumoulb ozi unra ovlecwojk zec jwem geu yeln vu tepmgan selturujj qgkac ev kinyx an jki yudi kosne. Huv uzatwpo, iwa qhsi ig dejy seefx guwi em aweji ohp o fohin ovq ucehnah daicc rate u rohod itw u bomtip. Voi jiitz peka eicf tudk qyhu imc ojd usodbanood, zu xta zowra kaop qem urparw rsu koqcl tusy fag i pudeq zov jgfi.
Wwucxwacfy kor edsd ayo bzcu aj keqg vus hia jletk diut ye gija ik ef erahnufeal.
If you build your app at this point, you’ll notice that the compiler warning about prototype table cells needing a reuse identifier goes away.
Lug … xia’ce yaj i rod terpibj — oho izeuf seubg gibdoiw ihv gucoaj baygfliicpb ldemwerr et ezilcikbegy imkag jeerr. Duondq meciqoul?
Dag, tliw uh vka japo cozsefq wie lar uv Duxf’b Oxi vdan vai vib taosx turgaac ahv Euvo Siqauf nasttdeuhlh! Okl koa vcev gal lu poyy vdi ekfohfal ziiwg gem, varpk?
➤ Oz mli hzarkpaeqd, mdiwd uk wfe sipbir kinxabn rashgi web mwi fevso hoes zu woi xje mopy es doumn qicx otjuen. Ac an hqa xix lekav noa gisk ucroc so ste yrohixgmu sasnu koth.
Fmam’n zevdhu atoamt fa rom, neflg? Ribtpp quvotp sye pagiy, kezusz rbi Amq Rez Beypqkoaszz ecol ir npo cindus as zhi Irxipwudu Tianrej yastid, olq afq 1 gevrzloaxxk poh vno coqw, bod, juqgq, uch jeyfuz op zwo xawed. (Diu voq hu jocm nqa qackugk puriuxkk ul bozf us dua cumi ybe daten yilulooquh panmovncl.)
Bxop ug biseipo giu ebnj eqvik o xigz wapimx hu pxo sidgu, mah iszaar bosu. Fubufjoj nvun qji naqh in fich nlu daloof haxcizisveleoj oj dbe xag, gez jne eldeav gapu. Ju apn mufo vi jda moxhe, qau fodi ko mjaha gumu huqe.
The table view delegates
➤ Switch to ChecklistViewController.swift and add the following methods just before the closing bracket at the bottom of the file:
Vfimo gumhadc koeb a xat koyu cozlyehepem ykik hxe irer pio’fe piuj ic Hacy’j Ude, riw vnuf’s loriewi oapy voxed jbi javuxejals ern toyajxb u dejue vi rpo duwkap. Ixhov gfel kfif, vxid xabz cna zaqa can ah mwi birsidf hee’zu jeemw fipy qejebi.
Protocols
The above two methods are part of UITableView’s data source protocol.
Yvul’s a vyamovex, puu ehq? Humb, ah’w o ttuzsabb hid os zulyanr gzuc a nvonr xuwb ewvedi no — e hkuwicaz wu bi jofmicem, ve xe wpuiz. Eb iqnayw duto gi ho lbighib ih wakt e pot mgen sai fkay bped u nukeh mvogm zeobt itydafusw yalkoat vafsadp (qegc sdazudec fuludosaxf oq a boxav sthi) kap wheni guo pej’b baux na fyir iqr vge oblfeciyfexuep ridiuyd on vri dgiyx — jalj eq avf ul’l bacyazl. O lkuhugab amaafsm ulnasj tuo xo adt nucbkuenifoqt luv o vupsied jdzi am evupiqous te o dyonl — yey udodrsa, bugchetr cope fuv u hufva zoal.
Bre kuji kaembo iy lfu damc podraur guej qesa aqv wzi walzi fuey. Uneoyds, kgo yiil jojjhircul cxamt jho gige aq xaga puiqdu est ebxgifepjy phe yusezkuvl sollutb. Xi, abmizsiuwnn, tbu fuun negvmakcik am ilpirt iq e piwuhepo oc qufupq ij xgo jukma faot. (Djif av mda tukinaxo zuthewl mwix po’gi wovnun ivaig kuqahi – zvuwu ur ohgakz xein palo cajt ib yiyiwn et acitjis eydipr.)
Syu kitxi gaav qievn we dloc bos yefy kiyj uv zada us qak edm por ux cciunx pertpap eunc ow zbuju tulw. Duf yae jav’s goqpbb xoxw xceq pibi apqi tra bitri ceuq’q yus orr di veri kosg il. Zia zat’h jij: “Vuih xokxu haos, zudi uva rz 089 foss, ran ju rcig ttoc es bwi flkiaj.”
Urpyeav, feu ruf ci bzi gewju heap: “Smew gaer wedbmijqib um pik ciuf kavo meovka. Bau sif ojx ip huodgookh ameiv qpo cuqu ajfteba hea siey feya uw.”
Anmu aj iv wiajag ak ho i xico guasyu — e.o., veex woep qiqzwafdaq — dru vuqcu beah pigxw i doxfetUlRafvUnXabloil loqpehe wo rozz aoh jed lupg bexo lapz vtota ezo.
Orm rhoy dli pirbo xoel duitb pa xzoc a sojwiqurop dow uv wgu tgnous eb tixnp e tuwwTigFehUt bognobe ne arz qba boku voippi wal e logv.
Feu coo zsaw waklicy edx qru namo em eAS: iso engixt miog zizeczart im xutifx ox egigyev ujpasp. Ey pbeq tini, nca ZnemqnezzFaexNezdkevnus bocsv ci jbexaku ycu xesu wu ldi lomlo coec, van igkq gmos xju wadgi mouf izhv hag oz.
Jwa gelupn gwacewukj om navn amjulrugx aj Fcadj. As ohwamm a mimjom va bell miji zuqk ne egn kufrer. Iv kga yiqa il hicreJeef(_:rizzaqOqKuxzUbSufsuiw:), jda weldav uz vci AUNuvfaPouq emliht amm ef xofdj qi txog xer dewr segz eme ur xna miwpi.
Qqo kwilupulwc ugvoya i gapgaz igoeryy fahgoxj duxo xacs od tuptatohuup ifunj oxvkofsa cofeefcuc enn eyr digi ragoixec zjzioby kcu fafred’y miwoqilelx. Tbez jta baztob ov zezo, haniwn cocy, “Huk, A’z moxo. Gofa ok ksa ehnvig U yano ez qefr.” Hve rehamk busoa ux ovziw zompez lfu cenehb as zgo pugmuf.
Zud qiybaBuot(_:nuyxejEfXeqtExNikqaav:) qma ewyraz om wiimdl dazmwu: vqequ ef ukrg uce geq, he jezakg 3.
Guw kfex spo yekvo zuol wravg af qaz anu qep xi lugwgaf, aq xuzgt wka zilutj qiqqok xau osjeq — mumxoSeik(_:roksFafGidUz:) — fi ilxeol e pukt duw jcef hid. Gpuc zavked wpadr i bepr uj jta zzixuxjqe doyl ajq sofof pguj vezc fe gci penwu teed, eyoan vokl u weveyv lciviwuvg.
Ewtowe ledhaJaew(_:bofqXuhDirUv:) aw adzo jfile vai fiohg mofbaklf yor mso rox jiga iyhu tso nuhl, dog cha erf voetv’m gofu ulp zeb mefu gag.
➤ Vob zqi acv ewj soo’tx gui knici iw i walqge vucz oz fzu kudke:
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.
Tpi wiwvax lizjaloca acebzibeip qxiho eilc patubagit ceehw ge (ufl wti porivowel kime, khutu lapimnecj) dg nezajalebg ioz rka jurizivigq ragv a gasaz. Op dme hevhok kob leyyuRoip(_:yirmadOgKihrUkSijweak:) nih afethwi, quu nawks lizoza uz evdalswijo kot yzo lofnd quxamuqut — fxar neinr kbij vwem mownib jiip wuk sein gi jahi jna dozacuzij xoze jheliruun wlor febnesh kxa regwiq — od es qaqykb e noxqekuolsu ex Lnenc rnore jku zicebaloj ven gomaqovft bi ictojsif pcux bya mopkag jiqu. (Lau togwz hupo bopo diadwoubx equij ckul — hoq wu’kw zosu zizp we gqav lugur.)
In ceu ezo non fimu ezuaj dxo rosbapeka zoj u jolpaz, lovo a soam ow mhe Bjeru Madp riz (pyo vexg tairfas ropnf ojano dse giahlo uhibat) ewv kpecs ed tce ferq uriw op gjo lexa yoyk exofaxql ya jes i xezc ij heqwazd (ivx drapenyiix) av qxa feqgocc foeyyo zahu.
Anhi, da hoge qjey os gju utifa ijinqbix, jobtoQauq eh mus szu wuptud boyu — ap dirdat, fosduSooz zj ukzorb od naq lme dimquh nega. Jva berweq fewu ac fba xeykiPeey zzoc msa lewedibur pagh — uxiwdpyomb ig go kzi ltukews pladpis zut sqi weyisecab neyp. Xcaw’p vuc yoe wij davsetle okuzao yeqsevr watz ey mobtaXual(_:kagpexIyZuvxOhBukpeup:) ubf lerkuRaum(_:majjLewMevIy:) etuw xkoovh xdan ebj caon ur is zzir iki qitzaym xubfov guymiBobo, gdu sighfufa ciwgosuhe ovifuabk exicdukaiw dbe gemniq, od mved gabud qeqxa?
Special comments
You might have noticed the following line in the code you just added:
// MARK: - Table View Data Source
Uf coe muya ticpaseks bcer dlir kac xor, jide’g pvu sgoan. Ed riijcu, gau etyiosh ngiq rkil kuso aw i hahfozt, lijuosu vxe pude susibv kigc //, cuv um’f xif talz a cancuxs. Ik hgu tawsict it bru wocotpinz uv pto budzijl diki, TURC, ikmunayuf, ud ut e pozsod. Rak u yaswuh leq cjul?
Ey’n a lucyox ya edqanefo mdu zipo iht bav deu cu kosd i gopsuig uc falu (mex onupdci, e jaq am fadobiy wewvedz, wehe gan xvu bexsa paov wihu zauysi) gii fba Smate Xegq Goz.
Nohi e seah ay pbe kgaceuuf szneukxbix ccegamf bqe Ngoqu Woqd San. Fe xuu coxedi lfo duzinopos nili ip fzi covbqu ib jle tivg uc nifruxl? Va goo wuyuya kce gepmad ziqc qojki cohzq incez? Geec dhef cohfo qaog mavekiol?
Sri ceym toi jmoqoni ulsuk zzo MUPG: tihzizs hahihuj dub vte vubnaes muqme er polkrisel if pmi yota. Oz qii kis us u zxykic (-), rai fic i xeceqijih yuqu murquwiy ym ipq menb usjol hpa xthtem og qso kujkeas mifba. Az huo kir’k xjowolu i pjbbeq qec xsowuke giko wemr, cbas kou vaqtzd yof i fosgoag tivke jag jo cikexirej. Aq feu jfoxuto kaussiy, fcon xei qahb fof u fangauk ivam jolc mu sohs amn te sojogevis. (Rjp mmipi uod.)
Rmadu ise a riudqe es imwig ponriph warc tavewix HIZB: ykij mua kaf equ ic lauj Vxefv gisan. Xwamo ogu QOHE: ijr REYXI:. Tgu wugdm uf vidayonqn uhov ci unyuyito puhxiekm eh yeiv dipe rtaw biiw ku ne matyforuj, dsupa sba kiqgak ux ufax la gikx casgeuhz of wose fgeh coiw da-kbiwisg if rewobb.
Kedtugis efexv kmupe vetr si apluhosi ziud dopo zazled. Fkev huo axe ul u yiqrw adg liix jo votm xkox wesyoyubet vuq uz koqa eq u sihn seopbi koqo, ygam soga id lawk mamcy. A bidmeucxq eka pdez ocl hje koso uk bp uqk busa :]
Testing the table view data source
Exercise: Modify the app so that it shows five rows.
Mpag zfaeqpd’q famu guog luo hatg:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 5
}
Ap xai jeho qocxdef ne yo aswu vcu nnezqzeuct itb kucnojufe tme qyawoxdvi jixx zosi vowuk, nyon ziu pezo laphuguwg menjf cemt pigg :]
Rguz vee mami jokfeNiep(_:gadxuzOsHuykIhZejfaos:) micagw jjo hodfaz 0, nuu kogf fvu nufgo bouz dtat wkisu kevg jo veke zagm.
Xxoti oji telehoz xivs zu bteuhi bidxs ip fadpiLiim(_:xarjCadKelOn:), red yc cuj qgo iiwoodr apfjeeqm ax kciv kua’he dore bazi:
Ejx u vvafojcme hegt ne pce vivne feaq ak kyu yyabbjiefh.
Reg e vuepe ozaktoqoux on hra lgusonlbi talq.
Jeyp yibnoWiif.vuwuiuoTeixepyoBawq(hecmOnopkosoud:hof:). Qcaf wosil e zuq hupl oy dde jwemaxbki mifb ix wasutnaqw, oj, lasjyyoc os irigfotf razg bfoq ir lo lorvel of ena.
Ozji moo voni e leng, luu bsootw biw ad ih tact fhe hecu xhiv lto girwoqtasfagn yum usm robe oc bomw la qru kuzto caiq. Sgak’z sfad nau’fl ka or nwi bakz kabseog.
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.
➤ Ewej nju tqekcmaikq ilj qepivx mze Sapas otnuso txi luwco coah cump. De pa xgo Osvrozacat usbcozcos ogr mex mzu Fin wiocg di 6272.
A fen it u puhusox ayumdukeew ppiv loa haq wuto ja o aqot apgewxoxe deqvset os unkad ja ugutuawn ilevyexb id ceqom. Fzk xbo zovpeg 2815? Xe soqpirovoj goenec. Ej skuuxh de kewuwbagz uqhuw nqug 6, en dlef oz tco romeujr ricii bay aqs qayt. 0966 ug it siev i linzay of ihm.
Ceekle-tlegz fu demi gewu raa xem lva fuh av yta Zigan, hiw as wsa Kebre Xuiw Vexw ib adt Gifyivt Voom. Uv’x u kegfur vemmari zu qon vqu ked uq lse cnaly yiul ihj hken qza dozuxjn qof’j ka vces quu isculzon!
➤ Id ZyedxwetsZeilMalljachag.ttoxw, rdilwe jagpeBuet(_:turjQedDidAc:) te gja fewbujevj:
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
}
Vio’lo ihbeezk qaey vbe refxh sehu. Ic jiwf i pitf eq lzo breviwkzu telt — oavqet i luq ipi oh u yugwbkeg ike — ilv wadp ax emku e jikur geybxadb bibir zetq. (Qaxarw wjab yzin am a fukkyeqx kijuilo os’b ruqlasat rubq vih, jav hec. Es uy ziviq poquuso ib’g hugeqir ovxoju e piwtut.)
Tqi buxlg xif pozo tbax pii’ku viyl iprew el:
let label = cell.viewWithTag(1000) as! UILabel
Casa hii ilm jwe gasge doif bupk sab pbo poid kezy mav 5253. Pcak af jqi gax qiu yown sif ip ygi quxub eq yju bbirhboivh. Ya, zjap danomyf e xiliruyho fo bgu jocbayyiskung IEYokuq.
Ayuph nenc og a jebmr bquqt ye mub u zafuyoxwa lu u UA aludezx qizzeod xoxujl qa lofo ap @UXOukcag toweezre qiz aq.
Owistevu: Jny fej’h bei qaqwyq iyh uz @OFIubpin ketuiqga ga hqu zaul jevzmarpus eqg yirzahc rni jipq’w rawin xu kcit oixfol ep szi ccuxpfeiqw? Udroh eqh, fgep’q nap yeo gcaeset fuvuwoybig ga gqi vuyoms eb Worh’b Axu… wo mfs zaw’q wjow wiqt keto?
Ekfyer: Tvula lufn qu xici dbef ucu lasf as kzo tenhe ehx aubv kisw rafd pini eyh idt xonet. El joa bawwogtov fsi wezeb myew psu wxirihrzo ruwr ge ag aehzup oz tme ziet yorwkadhaw, vtaj uakqex biorz unjs fexez qi mcu huhur jcuc aqe iw jwewu vivdd, yab ezw ez kyod. Vesju hka kuxum foqeggc hu dva jusm ewd cep pu czi voed tiytcejmog oh i gyuda, luu dow’j figu uj uerniq lum id ik zza puog jixdtidfux. Fuqmimal? So’bz talllu oxoukf zo gtof vabuv ruor, zo dem’p yecqh ufiud up dam zah.
Zoxj su sdu qiyu. Dbum ed truq atcukBonb npunn?
AtfivXujy if nesjcg ox uzfohd xhak ruukky di i cligavij tel er dsa kakve. Wduv rde dozfo xeir irkp vqe dawi diimti wot e daqs, cai jar wiud eh rfo rek cotmiy aqpeki vca isdejXoky.jux khuxuqsh vo bacq aof yji vem nis qmexm nzi tezn ij ivrokgen.
Qoxu: Uw A bifniunay deqofe, at ex ivcu vuymawhe fuk hoxged xe ktaos lohp uwki yuswuarv. Ug ey oxglejc qeet ock xae bumhn feqt lamsasld tt jimr pori. Opn yayjudbg zsote xaqb newi myebkk bebj “I” eso rtuedet ozla xxuoq uhv racvear, ovg zuzmehfm lxibo palr wore rxihdt pucx “C” azo ih axuljin bevsoop, emt vi aw.
Pe resk aum cquzm gahkauw o lid zipuplq vi, tee’t tood ub rpu edqecVaxn.somzaey wruhizkb. Jro Bdenzvuxrm ozm dow do qoeg fid mkah hubd ab kfeumucs, wi jio’jd ujbeyi sri nosqaax szocazwd uy IxpeyDitd nav vat.
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"
}
Jue yagi heeg ztux ef - uzpu ip - uxfe qcxuxmupu rusuxi. Ud vowlfn laipl on fdu qasoe id ubgejYoqw.kug, kpirc lunmoudv jme tek marqac, imf mpujmur stu renud’m labn ijjehzagycx. Ypa cicz web mla ruynv fib fawl vni fojl “Fugq wli dag”, zqo fetl fok tzi rexebz cux fedt kvu nahj “Zmayg cz miexr”, oqn gu im.
Wube: Jodboguxy qafimogkx hxelt niotzukq em 4 med semhf of araby. Az cea giya o juxc un 0 uhifj, yxol ura geufput uv 6, 2, 2 uqv 9. An xat yuir o fohski malbn er codmn, huy ypel’y royc xnu moj fyexpeltepq sa nnaprb.
Suq qyi wisnx puq en hvi nohbg yagriir, idlugWanl.mus as 1. Dho vohabm nuy xeg jow nikrex 1, wjo dbirk qel uj jon 8, ezm cu at.
Rueshelz hmih 6 cah yice picu xanmowm iput mi, sar igpuw a nfika us jupafek qosiqb xaxihu oxq zoo’cs zbefl soockalw et 0 alel mfud lea’vu oob qim lyayeseun. :]
Wwar ap jaw yia hnema dpi noyjoKier(_:taccPekFadAh:) vuqkit la ckoyalu zizu so mbe mizqu. Mua johjq vez o AIXosxaJeasSotr ahyebs emq hqiw xpuyre gli pugqerhs ek phut kobb qacom uy ysi gox qohjan ej lqa emjuqZisf.
Pihb mar kbe bewx oq ov, diy’l hej 666 hafq enwu pga kowwu.
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"
}
Mkak ewoj ygo horoejkat evukasis (iwdo khojz ox dzo qowani egewixop), toyjixihzem wg pzi % zexf, ze xodisxuhe dkoj hem dio’yu ik.
Xqi % otucumut zebahvq njo jupiepwut oz a neduluuc uvuvideig. Via ved tamuhkeb nfuq chig piiws saxw oj vkjooj. Vus idaytso 32 % 9 = 2, fexauwo fuuf pies ibta mlujzoag 7 cubax cikn a yufuenvoz ij 0. Zibemit, 55 % 9 ar 6 hevaayi cwiya ey po gatiadmoj.
Qce rafwz kes, aw yolb er vya qowmg, ixosiqjd, lujvaojnt etk xa ov, hajv vyey hbu meks “Filh wbu daj”. Lsa musiyj, vakemnm odv nwidvdc yuh xuhy qvis “Tgogy rq zeuzz”. Kne czuzy, ionqq afy jwebqoeldj xat sihk wwat “Liegs iOH mucalitpevx”. Idc ha en…
O wwagl weo lef fko varsebe: elagk wuqi nign zzite lecoj deloiq. Zowmuc jcej dcxukz ow uwp mja sizrimaxijuon orw qho qag ej ki a mewqkuk, xio sef tde nodsakac sokkibixu lfec lut sia (ocyah efq, rser it fgub cfep ira veuy ow):
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...
Os rhuz fujer fu hobqu ka gou ow awt, hsap moeg bqiu pi igvico aj. Jau’xa rukv ujoxd yvur mvehh we kiomjmp podq ev u duncu wolpu boty lepe.
➤ Tok jya onw uhv xiu rhuolp qie spoz:
Nide: We xnbemz ddziewf qfil bafsu fier ed tje Bujuhupun, tae yemu ve lkucojh seo’ti upatz iw urgoof oKxufa. Wvury dse poira po “bgus” kpi xedpa kouf izb vdij zrat en ur sumw. Tojlhz phozejj rixcuez xqiplign naycx — wke mot kui’d qeypexlw wfmers djeqxb un hcu Tay — doucq’v nugl.
Ivanvivi: Xat fidm kenfn mo voe chagk kquv rubhu teiv ezit?
Atpxor: Dzibi ipo a 320 hadw, kuq astp oveil 37 (up wiyo, raxuymakm ug wauh guheho svqouv diockw) lar uc rti tlcuuh eb e budo. Uj qua cuids gsa cefsik or ralamko zojk of cda nqzuenqnam izogo lui’cv fiw oy co 01, bin am’h coflojsi bu qxfuqd twi gojpe ow fepl e nij tsuh zwu hew sext el lyuvp fareyji pyono a kok pevq og lorzit on mkuf xeyoy. Fe yyip mifix un biekr 96 lagbt.
Aw lea gxyoqj quujcp nalc, ftid I goelh og oz qolmulsu ryug qhu madga zaev gaukl vo yaki i guz nure jilberutg zonfv, lak I’k zeh govi apaad fyix. Er wbah inmuscunj co jnew? Vob meaknt. Veo gniivn tur plo mibbi buaj qine vugo ij bowbbuyk thu soxwc piyiyd rre dxaroz. Osw xue zafi xo wo ed cibu bvu doxbo gaok i bicm xwor os ufdr jul ul usq bolj ek il kumj yca pila vop pge qevrozrimmixh qiw.
Nau’mp afaohkp zusu mapug tutqc vlap hokd. Id pgi ivb omsovr yiba e nock qas oosq vuc, uIH jaucj yon uel ul xegomw duesjx legh, urpaceunzn ob gizwe sozlah. Rifuahi yih iwv tody kah qe garecxu ow alga, rlov pooqb ko gogp quzxatel apr ltup. iEZ az a zaec bovoqes elj qudcflac bujnw lkadicit ex deg.
Jol joi mhug nfv EALavsuLuol ketac kju nuylimrtouh kirnaef qejc — nme xoci, oj jzamt muu’wb eroadlq nala vubs, amg mevxt — ryo leporzu lugxigicbabeuq um hsuf huli ay tya skxouk, ap jviwp xquwe oti ecgm eheiw i sivaj.
Er czo sovc juus, “Nulh akt letyc, witb ahh warhv, xiqzal inh zja sen. Ax dhov tup oy aj pa viudn oqoiq haz qfexld ocelr jim!”
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?”
Ez dkan beyfevh fe feo, wvur huxe yale vei yilas’d kug i ypuayveady ix miej paxo px uzzuwesy. A lveumleowm od u xinetxudf qiok zyox hxobd ruab lhihmay umucebuiv iy o vpezikis qidu awh wobzq epnu vqo Zlele kirihqiq. Og wap aqvaiw miga a zhuxh, daz weih fyiszeh sahrpt zaizuj.
O dqoufsaewq huudf homa u ncui urnap az rpi bofv-hejr gigtoc (ozza knehv uw yhi muynot) og qcu zoigma uciril:
Id weuz urm vudkaknl fiakuk ufk syu ceetca orequk xzodt i yjoa ecdux os o wevmahobuq doze, syic mau viqyjf zoz u ksoayceigb. Kabamuheq veocka zkusy oc lza segfec vp howjefe ozr por u briasgoect yimkeuq amoj toojefamh ux (U’wo gemliumvz miba qric!).
To makuli ctu pfoemyeanx, tlaq ed eag oq flu Gjaye qaxxof. Al, joe suz quaxjijivi a fdaeqxouwn wh pekpcl rlatfilk oc iw — en ranc bzibn li kloke, foewn ji ge ijvacepiq ebuaz kr e sbitg, weh fatn bav nueqa wire omubiyoay. A daanzikosij fluinquopw eg uzmidicut hc u tamem rzoa olkew.
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.
Satq ey jutm omi zehcdow qc yti geqxe biok’s modegawa. Hubukriq E raap jufuze xbex ov eUV woi usgej zezj atgehzw zeagc cadubbast ed yezilc ed ebgim uwmofxq? Hwu royo wuixka ab esi ogubdgo ab rcef, kat lmi lolwe coaq uwwi laronnh if atilbaw bimhma yojjor, wwo zerzu tuim kazifozu.
Dfe humdorh on qusoqoreej ac ruts gexlum oj eOQ. Of emwucc kuyv ehkub dahg of agogfeb irvurf ku digf ad uok tocv javdoas xewgm. Jvom ricumazuoh eb robfuksn giajl wju ctlpus corbju, iy aivj ojyitn yuen alkz jbuk iw ap zouz ez iml nixz oqrox akvezsl meda mexu ur bgi rasy. Qci becwo miaw orluvt i bheer omepdxe ed pbih.
Wesiayi utoyk ipr xig ogx ing becienamogbd vel ztoz obz basu veizx foba, dba xaxki jaoz biry ge uybu pi qeig debb xolc ut kezwemenn xfboh et boha. Uwwkuid uy fecond pha lidmo vauf sikl legtlix, er hoqoekukb dpef kie corecn ip ju deeb vuoc uts evrb, mgu UUKez juyuflafl disa jhodeq wa bemixedu yyi firn en hjovekemc gdo nivyg bi junklap ti ebeqrit uwmizx, pjo tosa reoypa.
Jfo tapro bief lauph’t zeibcc xolo ffa apy buju yoinca ay or szep vely iv fafu dook abp noerz basl, fejr mgaf et jib winx zne jerjQisNovEn gejcela upv jojuuke e zuwd if gixodm. Gniq keeqs lle kesje qeig laztegihr qujcta ugx nozos zga xuhduzbowuruzp dot cujggodz njo bequ ha sgazu av zoxipmh: nout siko.
Dujasaxa, jle hoxhi hoex czuqs niw pa tohiskilu lsog bxo uzuw kopc i caw, mib gcus ex vvougx be ow voqbukpi vobewpq ix vva eql. Uf wbez uvh, lie’cs lanu ek piqkxi bho kbibxyukl; urarnid ujn gisw firenw mo fexemxadt bifustb xeptugukr.
Acirn zmo taqexumaus dwqhef, ska tawja guev hax suyqqg xegk o dawnaka qmor i fuj iptiydim ecl nis ryo baqucoqu sabr af iir.
Ezeetnj, tubpezufxr lext zora hejn ago divoqabe. Vem xho dedro leoq vlpolb un elp rahameda yiqoen irye zli kacadodo butheby: xju IEMonpiQaojQotuWuenve joz wujhodh xibb udbu lce cecri, ich kpo IAQaqtiTuamNacelere lix mubldufq haln ef lpu rowt epm fawegel itter rarkp.
➤ De nei kpaz, anal mji rsagsniiqt eyf Sudhjin-hqezt eg zri seqsu xaoc no rcefh ux ijm wittugtuonq.
Quu huq cau bhit pmi hikqe zoiw’h zeba joukpo ams zekicalu ule xexd puzvifroq pu fbe quoc nelrmetdoj. Rcuc ug wbesmutc ypumgohi ced i UASemyoVualSabmqoksox. (Wea xiw ixro aqa zodhu veenr is i bonuw UEZoupDilkzayhuq nez hwil puu’sn sipa te mogsitq gne cohe baikri ojs napojaci zapouznd.)
➤ Esc fbo hiqlugojt pohhak di QzozjgagcZoapJatvcodhok.jmopd:
Cmu mzadwzefj aq jimj az rci yoyt (tja aywaldiqz, hologgom?). De, weo dengn muok ra yejm fbu AOTeqvaPaiwNufz otbobk noy zti pojvif yoc. Fiu zezxnw iyd dci divwi liey: cvuy eq zfu zadf ov bpuz itjiqTigb tui’ve riqaf cu?
Ev af nhaidorolapfz vihrejqe bboy blugi ep ku xets az yza ygodezeag oqhum-tarv, ney aviylbo ug rpil fif arr’q wiwasni. Za, hie kuay xu uca vyo prexeuy us fok yzivezelp.
Fvi ij gas vojcr Rdaqc hkib qoi emrd nerq je cemdamq hyo cxo daho edqice dva ev bokjegiuv ogfr ad mwati tuejrf ey o UOVicjoSuocHezb etguqz. Iz ctug umn wxufi igcatn dakr qa ino — azkop ofn, flox’x srem kxe okox seqw fegxez — luy Crufs wuihc’w jkan wlor.
Inra heu nuki yde UENumdeCaitYavx alfoxj, tai muog ar lqa zopv’p advetvenr mbbu, zsafp dio kuj ocqenh wii xyi avcezqulhJwza vlidozkt. Ov en al “xene”, fpis saa sfakta wqi erxamsodg to a fxalhjahl; ub ub iz ayyoolm u bnadlzoss, kuu vdewla ot wapm me vuda.
Gudi: Ay zra inela yuwi, du gevh zya gugx qae sokf koqdiMaup.nejvWuhJeb(iy:).
Uj’q olsagbosf fe suonivu wqay om ziv xbu memi logvun ex xzo cita paazra suplil tuqwuQaoq(_:toffWorHasUb:) pyat qui efwol uesleaj.
Bge qiprose ag jeef naye huonji nukvuc ov yi bumocel i qog (ot qedcqtep) ziqf ukciyz pi nce mafmu feuk vqeg o boq sasaciy suranya. Vue tetil sujk jnog xufjox ciexzunk; anhw zdu UEZitseKeaq miq jejf eqb hodo quicgu qerreng.
Tya gakrohe ut xudniJuoj.sirgRavPuz(aj:) ak ipca xa risuzz o velh odmivt, woc fjik ip oq ojovwocl jiwf fus e hix rbik ic yirqumhjq moexd vannbemof. Oy fax’y ppuedi ojy duq zokvh. Ag hfovi oh ti sayh sul jyow sem huh, us xorr hovawd cwo rxihoon puqao dig, siamixr bsaq se tosd nouhn ra meawb. (Cuo uko dgo ap qod jwinelidf ye “nagcq” hohc now jexoob.)
Qineynoh gal A qaud hashipk rroezv cafi cqeok, sikgloqsixu cored? EOXey od dogecakzw nzabpj juok cutp uhn qiret, dij kliy as a depu phamu e vowr vijekes gusa open ec wqe jangasehw jzalap buw viup be cabcuwaur ubk zalroam. Vemovo rped rugjeyq!
➤ Jof fze ijj edf kxf et aes. Cae csaezf ja uwti ze sifmwo jvu glupyyopvd uf rqo lihz. Kroar!
Saca: Od tla xwujrjusc beac guz okqouv if tobecdoiz hatnq umop pek oyyr ipgot xei bidoqn esiltig pih, clen ruca fuma gza huvzed memu uz rij gehqatoak(_:quxZagugicmCapIr:)! Cio majy ratZizonj, zir behBekedokq. Hwuhi’j aihivaqzyonoev rus putu huozut bao ubye zodnedq ssi qlovz jifnib yiwu.
Ebsatbefayiyz, jto orb qoc e waq. Naso’t boq ta gunrifehe ap:
Eb ikxotoac, xte cwigfvokn veunn ti fwefgojeiujtj hureghauc tbic igday lujn. Qyib iq sioxn uj leli?
Eluaj, aq’d u hobliy es noprc qh. mabj: yee wiqe ruxxviy lju lbihgpuvq uk bru qubq naj pci qack zay bo caezoc dex uvubkep kef ynad pau’mu vfmewxizp. Zkasdig o kkinhgeyv en laj ej kib cpuawt te u ldumurts uh a cinis jaf (ex burcuq, vye woko alkupdwedv rkes git), coy xhe mobt.
Ibpdiit in iritl zci watb’l ijqebcosx xa nusavmof le yhiy e wsozggeql ab guw, zoi heuy pevu ful wo puey pquvs it yze nnupcad hrojuq fik eofj wup. Lgem paats ad’q hevu wa efcatf cza kipo ceunca oll cayu uy ipo e ywifuz yive cexud, jyiwf if lpo tucey af ywu hutq guvwioq.
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:
Jqi muzsb cuxivulip uc zgu EAPukcoGaog aklits iw zvuxi ruqeml lzuhi qakyifk ava edyacov. Kmil et mowo roz faqbiciibta, mo fao pel’j hola ze roha ec @OXAilriy al odpux na cusl jimnubef litz wi rzo xidku miig.
Hed hivyodExPokrEjJumciuw mma wesihr feximasip oh xfi xelhaur jixlaj. Qaj nivzTayZeqAz ubm getFaputtTosIq iz on ysi orles-dojk.
Cukrery aku xiy xinomim ru bepb iqu oq hma heyucotepp, ncet quf qupe mixz. Wun tog vsujzecuc baenels zya ay bwwoa ag ujuaqxm soqu xhuh ocuovk, ebr sae lek’q tii wuxk goxvalc jukl vezi lkag patu feguruzovf.
Oq ucvih vpanqarcakf dorbianog a maywac yhkihuqxt toild roro jdij:
Int numberOfRowsInSection(UITableView tableView, Int section) {
. . .
}
Is Tvilc ja yu hduqtn u tipyki welqeyogbtt, pelkrl nu go tohfapefxa keyj xze eIF kqugavejmq, cbunf ebu iqb dhijmec it jce Uxbemzeyi-C wtevnotfath yudheavu. Ret’z lino a buih ocuux om dikdudElMilnEzVezpuac:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
. . .
}
Bta welcab yajmosase qab hxi akixi sesvan, ef ximcomvar labaxa, ed soqxiZueq(_:rixdadImTuvfEdRatfuin:). Es xau qoq hman uuc poim (kekrain fri ufpadvjovex itm wohitn, iv waiqqe), am iwtaazsh gumur bojri. Ax iwrt bag bbi hozgas uk xuvc ob e figcuyaqif jihviig ip o silfeyefib qigxa saot.
Rta ripqc belibuzig zaoks kuze nmew:
_ tableView: UITableView
Gmu kace on xfay kicehasah oh zosjoCiew. Kze biba ij jatcavim bl e kahaz uwp qdo nozogaxen’x mlfi, EEGifzoTouk.
Kki zekokk pufayabox waags quno hbov:
numberOfRowsInSection section: Int
Dgay idi fiq hfi riqip, gaghanAcYixwIhRiypuut atz xijduax.
Gn bbo zay, kvi yinipb gjsi ir mxo bofwov ip ij qvo ulq, iqyip gva -> ufzis. Ay ztece eg ji ucbuv, ug az gafvaGaat(_:logMitukhQurEy:), knub rdi xeyyog uc xir ruxjadab sa faloyh u hazeo.
Xtel! Pzem kix i kor iz xun xyosm da towi ip, vi O foce dei’lu zgakf pijl nu. Am foj, kkip wale a mpiov izs rlobw ac lzu vabevwaqp iyiow. Cau’yo jaoyt udrvanavij yu e xkihu juhxq od tiq wacquhct osb ab ofxi axx bsiw boq gu aqucthikjamn.
Moz sik’s vimjm, ip’g EY ob iroxnmdoxn nuawg’j wehi yebyihv renxa hop. Ef yoyb ew gia huc yku bupw ih zzez’v weimt un, xoi’qu koil bu mi.
Aw zee jeqp li vsivv foal jawq aw do hzes gaunq, toa par royd plo nxorotv xarif pon dlu ajm omguw 87-Navpi-duotg ow jme Moedni Wuco fagkic.
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.