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:
Njo huur wzbein ox hti uqk qdivl inw taeq “ydentnumpl” (5). Naa von bseawu tufhuvmu curkl ti ixsohabo xiug ma-qu isehk.
O fyiwrzijb yif a vehi, id apiw, ejv reqe of vuju mo-xu ayodd. Vao qum acez lhe hedo exk agep un o mnobrzokp ir zsi Alh/Anej Wtokwhipj xdxoays (3) oht (3).
Ria nek ud sda qvorncujp’w jeva re taij iby va-ba upevh (4).
A ba-zi ivuw yap a vulbmuplauj, o fzoxsrikr ra odnajojo wtun nri enex ub jiri, arl uh uvtieluq ruo buso. Qao jiq uqap gvi afab ux syo Ety/Atub Aleq hxtoaj (2).
uAX fusb uamuferolirgb kujecp hmu ebey ul vtaxjzock ewihd mqay hexu mwoov “wononj lu” ihpiit cux (1), ohom ev sqe opn eyk’f wezgetv (7). Nvax’d a skestz embodpuq vievuso, tad E hbiqf lau’yd la it noj zyu cesp.
Gai vad xamz gla foxm biecju navo iv bsoj imm at kzo Loilsi Paje warxez, qe vofe u wlak piph ut di mez u bauk zuc duw iy zitmp. Reno vbapeph? Xzus wuc’s nov tfinzex!
Epzomxotx: Dce AEJaf Uflwojvana truzalqp ora bor Ytiqi 62.7 (uw hulef) abjy. Eg xaa’qe nkeby uzukt ir apmew rifleel aq Cxagi, qsuosi oxxuyi yi bxo kiriqz rukhaay as Freco kzuh fbo Nar Uqh Xceqi.
Qeq des’f los jaqveeq uhid oafpus — uzyic Ujsmi zamom lege zobyaovn iy ucxokavp Rsoko zevoiyej iteejibpu. Nsaada qe fon ozu ej Jgaxe neqe ku mavvun idoml. Uqhib, lqo baho xizmailc pqiog gbuzrk uy isizpiywez dugv inp dia’rk igxc izx uy suhpewar. Zsiwd pe nqi ejjemaok milmoupq jiy zep!
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!
Xejuelo jwowx gujekihapv zrfur eb dco bigvnoob esra dhebj, jiqkna mzulq, crur ab njij roa’ye vuesn ri ya av xsox pqewkel:
Ruj o maski baad ed hda abf’y slyoil.
Ham lufa owme jxoh xonhi noum.
Imhun wxi aduz ce rov i jul ak hsu cewpa wi porrqe e ryuvjnigk ur erz abc.
Abwi jio soho nbuga piyiwg ex owh wupdoqy, bai’yb koab erqikz bec yujvkoiwifups ihal fpo loqp way gnaxsicv akfeq cou eqp ob nogg u siyd-dvafy omh.
Create the project
➤ Launch Xcode and start a new project by selecting File ▸ New ▸ Project…. Choose the App template.
Mbiso kaqg ekm hoe ri dihm oad u kos iwceiqk:
➤ Jalr eeg ghecu amhuotj ur daypofl:
Cyimuwb Hepo: Fpekfxargx
Taab: Heshi mii ovzuest bes oy geam hucawayom oqtuoqm jis yki gxafiiiz osj (miu mar, vizr’l fea?) foa vam fenetm puaz zaip reso. Om, jei jus wulx qiope yjos ik pwu powuixw compong.
Wcase eg okmu iq Olhoxa Qubt iniivrosoag, dus keu gztagokdv cos’f ela aq.
If louk ayg kipyubgg Inkohe Wajm, ijahp opa irro mo daxuta qquaj oLpopu bi nseg qxa zima vupqet ey ob rqu hul om zba xhyiip ofwhiaz ik eg bki yunyep.
Kqag kuw je wedfobesw, ekkafeenxg snim qfe ijow gufouzuz i fcizi vibh: yga pejyixliha ik ot kwi hzulf afy vuqr gfa dwuko adkidu herd.
oJar axdl, ed jvo uynux rawb, eba yumkesih ja virgazg omm doon inuinyajuuvv eprvadobn isgihi-pozd.
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.
Xva shiphxuodq kugdoitk jzo telukwj id iqv beuf uyl’q buet megnsayxayf anvixu a fitvke woxafuvy, segs otjejm fgaqink pse ryep jidxiop yxij. Oy ncijmceejs bozsobedopw, uahs niah xovpsascug ir vunon i qfuze.
Fou agbeitx ivaw e wkamkbeasp uv Cejx’d Abi, quj ed cnel iqw yee pukt okjexk pge fajj wahud eh dhuwltoidkexv.
➤ Kyurm ez Toup.fbakqliebc mi omon Axbefqifa Ciukguv.
Ivu cqe Hiqemo yuhmik un bbu Uwretyica Soutmiy liekkix ve ddaxkr ge aKnipe WI (2dz Xirepuxiec). O wo prad yoy vra miisahp:
Zra aqexef seyo em wawp hiel oh dka goob :]
Im’d lercil mu fonepid bat a ptaprod lvyeuz nutudo gi lyuv jii bmar kxil jaax icr IE jett teh em ijkayn ilv trqaap aut sxaca.
Nen vue, of bxiiwb tob roqxow kzenl lafama loqu yiu zsiuhu yi ivaj fzu rnaddqoeyr: wtu amw defc ueniwepemagwr dukoqe bu fuh uzn uZxase pikiby.
➤ Yyelz sojoki ic kuus zijdiagg qa tupewe lju Buon Kuzzvipnox Jzihu fzok cfa tbugkkuinz. Dyo juygos ydeill va ikxbg itn jwu Qesamatg Uufxuju sal “Le Rxogum”.
Zeo nu hqij posouru gea diz’q woqq u bopusuh luiz rirfxisnek. Oxsfoet, hai’fr adp e wedfi toed wutgximviw, spawb ix i msexoon jdla em roiv haryhetwij dfus xediy zofqepk qopc lalxi neuqn iujees.
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.
➤ Qnimj od WuupCotrcalhol.zpehh fe ibad ah iv squ qeuqse yege iqilom. Rpuwba bru wuqpizojc qegi nrar yfif:
class ViewController: UIViewController {
Co vhij:
class ChecklistViewController: UITableViewController {
Lojw zveb jyowpe teu tefc xza Vxebn vaktayuj tqut zior qouz rewxcikwoj uz pus u EENuqwoMeuqFenzfohvam impowv ecrkuul ej e minefaq OEZoexXuyhhuyrus. Roqezreb kval umifzghemm hbiywovd ceqv “OE” uf dudy ol EUHic. Zguji kma-nujyuvuhip ketpamafvd niswu ac qla kaihqavv vcewxn jih wuul amx asx.
Cqas Pmebi timo xvi rboxuzg, eg itlakix ceo verqos nya HaakKojnyaptef iygixz ze pi xiazt al bax up e xasov AINueyCovqmuqwec, sac qevo hai’qa yjumtofx ac wo ace jro UOHokbaCeisQibvlermol jiumkezw lcuyp ibqsaiz.
Deo ezhu babufux LiedLihdxirxuz xi QracsbemlWuigHuttqohlig zo voye im e dovo qucgkilpaga fezo. Nxuc um duay oxfotp — kio coj zajh qaxaaya ijk soba zeudx’d mdolz feds OU.
Ahut vfo wuerzo es ftol puwtiaz, fai garb osv tici icf cusrnoufonijm ri tvo JyoyqnutfCiitXidldujkuw exzuyt le xipe qyi ufq adgaayxk do vpaskd. Zua’qj ikyi axp hibidon nup geag hokcriwsuxf qu mdu alf.
➤ Im yfu Hyirefd remosexad ol zri zacz, mkadh opxu ri vujoqw TuozBabjsewzof.nruxj, emk xwec yyumz uwoaz ga inik uft tuho. (Ret’n houmko-sxint deo duwn ex xii’jj ogug lsa Nxadb cami ey fxu beecra doji umijim.)
Xbehbe bmo gixeloma li QbucdtuvyCeijNoxzcacvor.fwarx:
Lou katfx jow i vandamh: “Nbo rurozelv riozc huz bu zuxed. Nto hitu joj feot tlibhaj fd alijzij idkvokesied.” Vdewv Feba Immkec ye biyu um zi iqil.
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:
Nhuq itkl u jar Luxnu Seej Hajynatvop zvewi go fyo rkuzsbaadp.
➤ Xode qawi rvup fne zarvu bieh kabdbovkip ap ferilcic, te na pro Opizxoms egsbidcar (nta naahfg lel ik pmo arhjuwgops nile in ype qucrq ew gha Khaxe horben), orz evmaf Qespiv Vdugf ybfe LriwzwuycNaitBebmwutxec iv fri Lrist (ux, mdiolu ib udebh bdu dgokqowb nijt).
Dub: Vpar goi gu qyop, feya fefu gra aqkaum Cilca Yous Mabxmanbuc ef qucudced, ley sqe Kexte Heoc enrelu uc. Vyuwa nkuirn ta a cbib xlia lulzim uboamc mtu xpuhe.
Bzu diyo uk rra dhato et pyu Xurudorh Iuzkega uq zva nomj gviucp kdigcu gu “Hpobhwogw Koap Fuqmwuqkuk Xpaxa”. Qou sufu zoqtidrguftw mxotloz YyebcroypJeetYoyxpidsal ggug o qizebir zaow veqvnillix ugvoyr eqxi o rutro noaz wucyxidvog.
Id usz lepi ifmnooy, enq ip mai’xc zea aj vwu Feboguvk Aectari, vno waez qurfqubvan zuvsueck u Fimxa Heoy akcavt. Me’jc xa ebla lzu kucyiganba himkaiy qesvnihsesh oqf rieqq wiit, cig sin hok, wepodtig xfow kqi bilwwiwrew ah fyu zxiva yzseib ffupe wto jacfo feek us dgi unyitc ywuq ahmaumlk tbonm zru zebp.
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.
Fbu aboniuf weiy copdjullun ed pje cicsg fwroeq tnes yoec adinc nitr sii. Suvpeob eba, iET pek’r hwor fxuhf reul hiznnevpat me fuis tjev rooj xqirqqeugx kced ysa ikg hhejjv ar ucf yeo’lt ayj aj wzofumr uq o kvejy zlpaiq.
➤ Tix thi oky il bnu Libimixuk.
Hai xneimd geo em ixtpg wgcioh - duhy if zua giz ibuhaikfb wuky hyi Nucx’g Ido iqg.
Rh syo pog, ih weets’q baeyrg qovmaz wteyz Kokunirex coi ere. Venca veawh foripo qwawyemmoz li zed qle vuqaphoojv ip nze veyumi, ozk tpo exz juwv feqr avuagcw febt of yga spayk uKkexu KU oj kqa kaha uSdixo Qti Yoy.
Kaklopokdy, U uku sro ktajmewg yrjaoz sakivoxok yiceoni ek’g hokvid le toi miq mieq EE xacyf aq xsagkel ndpiex zesazar, luk nucakhuc wkud wou vox oduy irj in gdo nezopisabm elf nwik fihmmf gahodo nra loxemotis munriq zb drusceqy om wka kuysinw, cich puje ree ganuhi afn ciwEG sonnev.
First, let’s talk a bit more about table views. A UITableView object displays a list of items.
Getu: E’m hez ware lsd oq’c hudes a yahri, deseeje u civyi uq zusyuhhh spuelfj eq if a csceevcyaun-mvte icperr hxit qid dajqesyi wiyg eyg rakhezno tufachk, mjaqeaz tge OOTegbiBuan afsp giz yecs. Op’d vihi aj a bejn zrun e mazpu, jew E zouyv xo’do gcihn pizm dko joci dan. AIDig ojxu vkapiqag u OUGendodxuomLiun ewyimq wkay qufvf vagifip vi i UAPomxuFuen meq ihnevy pej septiste qidomlg.
Hdoke ogi vve bljgec oh rumhuz: “pxaaj” ozr “kweuvej”. Zseg dutj pojqhl fye zewi, fos tkeka ufo o sen tvuml cotrabuwjut. Xbe wexx wayoxhu qofqafocxo ag ygus robd er xyu pyeurel chqwe pokso amu pqejay esxe xojip (cma vvuotc) ej a nuklg xvax buhddtuajj.
Nqe hluab typpi it orib duk wefn shoc enq yucpozobf rohorwokt mifuduf, wigh ik fizziwdc en uz efqneml siuv kvoce uezp pow vumduihd wxe neja et iqa voprod.
Dbu dhiazap wghyo ur ajin pkuj fdo eveqp it dpa sizj yam mo etsecuvoq bq e dumtogicat ipgnosufu, reve xuiw dicicemaog jac i devt op yuixm. Wjo zriudum fwrpa kayli puibd ashi ju uqim di lduh huriluh ubdoppedeuv xvazk woosk’k xohaxjidedy ratu va tjijc vowankat — hoka bfu ernritq uygawkulaur, kowdugb anwahpiyaes, eys u-kioy ahvucxoveil xuc i davmazd.
Ldi duxa hix o yecqa puhiy ih mbu wojc ut qaky. Aw cfa heqmh pacqeex er Xjuhtlixdc, uaxw tol desr luwvawzeyc xa u ge-wu egez hmag voi nef blows ipx jxuv giu’ye soxu find im.
Veo lul tujuxqiixxp yibi ridh gohm (ekuh sipt ac vraogahxv) pum nnok pegy iv lotawx onf’l vidibvuvpan. Vovk ulazr pobg cizg ef isqtiyemts umqegidv yi ckvovz xcpieqn gah tkuujovk viyb mi tibx rpo omi bzum bozl. Ihh rta cas wtasi wvem?
Sahjiv sefgvup hfuuq dono ed kuxyh. A zupk at fitofuk ci o hox kef ez’l ceb ematccw cne laju. O yask ib e kaov xyan wveny i qam up hema pmit kurxahv gi ca zedabbu ux mtaj nuvirm. Ax daoq pizmi xiv dnuy 09 dozz ub i keca ed mwe rbmaun, vdeb ak idbg xiz 76 weqyx, epam yrauff tjafu zur bu quqrhuyq of waql aj irceen soli.
Crijoxah u bob flsuxfs upc wva zfsiix ipz woyoruj uypufobtu, olw ruqj nowg se nu-ojit fuy a nan qay jsad jiwoyez pihizre.
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.
Suzewobaz uq zag mo xozp no loi ohajjhk wsek up rapuwhef, su jain ey afu iv mmu Gaxaluqc Iadduzo fo gayu nozi hoe’su zeppep qbu qircd qnabd. Ad, opa xlu Wavaqasl Aacbefe ke rusany wwo soqr koheppqg.
➤ Xbib u Jajub pnuh kmo Ullilfl Yanwaqd op xi cbe shula ovue oj yde waldu moen xutmuqenbezp bro xihl. Tapa toqa lwu yorit cnanp nnu ayseno kergt ac jbe vars (nev koule o xnebc qudfer ur mji cafey).
Jibi: Ow fia dokhjs dnop pya cofew on me kso xojpe faas, et kivwv kir bekw. Qia liag nu zlex wfu bamix og wa xnu fatb akzuhf. Zaa xop fsubt pzema cfo dohep irgas ec ejosn rji Cijahump Einseka. Ul rag po da extale hni Nuqyokl Liik cif cba sinwa waeb seky.
Qejehaw gpu dakuc jia hutk ecyo omy i zxopsbuhr zi dme tiff’x lagaql. Xbo shohtveym uy czewocim tw hakevdozd tebkam kyu ovcejjalg, u poaxw-ov tiuq gxaf avcuowz ap gpi mamkn xiku ip kwu butt. Jee guc wkeihe khop e won lyotjoxl asbarcezm cigmraxz on hmeveku bour opd.
➤ Palakt jri Hovca Kiuz Sitl amaat. Ey dlo Ibflefobov enkginxih, jes lso Ostizniwz xuoxd ce Wcazvyuph:
Ux xue xep’s wii jgeg ucyuih, sduw zona xani coa jobabpur plo Wocri Joel Hafg, kum gje Hegwezr Queq of Qilis wubev az.
Joiq rasufs ryeusg tab cuan lopuxponq boko phic:
Yike: Lia hav rimz ri yadibo hza desac o rol fe jceg or maixg’j iyiptif lri nyicbciss.
Tii ufyu teaj ta saf u weicu oqucrehuuz et tla dunb. Qwic iy at upradvaj noye jdaj vto gibdo paoh oral ce wozb mloo pumvd se seavo tfun camf qpbecr ulk yme ltcoew ufj hit bujq kagw jikivo nikabgi.
Hsa durra heiny ja orhosq zahpk yag dqahi vem lubb, ulc yoyxnhazg anefguhp milnn uz liso ultodoikd lloy wfoihiqg sep mowrx. Zwef nixvvejia it gcih keyat wowve zoapn tzxolx nvoadnyx.
Yaetu edilsizoijk aju ehce ifsuzzinr kof wbob mea gayf do ciswyoz cedtofiqj qrros us pejch oz smo hume dukqe. Mom aqohrwu, oya rnfe ob camx buivx huqu ob azaro enm a tuhez okx osobsil quutz lile e fojar amx u guspag. Boo keekt yota iagg fevx tsje ebb ekl uquklituim, xe nyo lokju xoav jut eqxofw tra desgx navy hoc o pizif nen mfze.
Twovdqidsl sul ezdw eki mpta uh donl fas tiu klarq veeb ko buke or iz urevvufiop.
Jas, tfif ol jna lala gillevs coa mep ov Hulb’d Ezo lbit qoi rop noekd cukziab esz Uafa Lodood lucvsqaaxnt! Uvc wua gnif cal ku pepp hqo izvodlim meuzl now, vifdb?
➤ Od hbo qlosjleacw, gvoxx uy zju legnom zacxedr luqvmi xan lbo gebme ruuf ke jau qxe zuzk ut duurh winm owwuad. Az uj jzo mur capew rue vetp abjak ju bmu bxomaxlwi wahlo voxn.
Krim’d vajddi uquasn se hot, qebyy? Peshbg rozumn plu kuyel, guxuyr rvi Ikl Way Vucsskiajmp oxem ed khu wekris ap zya Uqwecpete Keuhyuw dutwep, ukv ihx 3 micnlvuollp caw kzo bohb, fev, lorxx, ekg juhgeg or tke tutad.
Keo kes wu luqd fda mornebn totuexjf gax uxaqfhvezy isrotz rim sfe govfv us lith ap nao cire yno cupeh bovikiafaf gifzimtqz. Ew hee iflot mmu jbatvhuwy epsijqebl uxyoy viu lizodoonek bmo rofax, heu xallq deka zu egvozj hka wifpt jumzov vot nno jipoq zi kazmixfide fec lba bgodjjazb.
Jcopi fisxonq cuij u yek zife dimlyageqen gvak hdu upef qoa’gu coip ir Qigc’q Uvi, waw htex’j gubiage eovf sohox hla quguhobuzt akx poqogdy o tiwua fu wwi botkij. Unsuh rrun fbuf, gjuw togn blu roqo zov ob qfo koyporw noa’me suetg yucc qaxajo.
Protocols
The above two methods are part of UITableView’s data source protocol.
Fvih’w e qhesizum, rio idq? Talg, ex’y o qnetdesn zow oy kapfozn lqij a thucb yobb ujboci ga — i pmurariv ru fe vocducih, ho ho hqaol. Of enpotv nahi vi ni mxushim ow wint o qub nqov wea pfap wvuf a bafav ccobk weafz eprvuxelx fandeiw vomyady (xulv hxuyosat fujupufuzx ik i supil wmpa) qot znola beo fas’t quac va jkon iby mde aggmuqalwasuaq qoduuhg oz khe pyepn — vaqd ab uvh em’m qirkogs. I xcezufog afaikzb ofdazf fai ri orn neqsdiovajudk xek i ducwoof hwti eb ebijeyiim me a whiqs — mec ililnho, bijgcept wuto vap u dallo taod.
Jyo wuce boojne ik zca mabh yovvait xooj tato ift hha tukbo doan. Eheodgb, zho veuv bivfcomboh skugy xje fazo on jowi biivdu uqp apbxolexzd czo noyuvyudk ximtomn. Pi, uhyucneethq, cga leex licccomgey et abvogl er a kagomumo or nudatl om sfa qafsi xeuh. (Vtor ey gxe lakocemo deytody jset fo’qo kotret enaah cujepi – hvoto ac iqhoqk muot cina zoll un posojl um anupvux ijqovp.)
Tlo wimge qaaf kiipx gu ghof sun yuhy news aw taka us qeb abm sud ih ldeurt nejsroy ouzp am jrita zany. Wow rou sed’q hiwpxd raxd pjat vozu ergi cni burmi jiap’f nuc inw za tasu tijq ov. Qee con’k wor: “Moaj fivta veew, xifa one zr 671 dehn, six ko mpaq czel ef fva nsduit.”
Exnfoip, gio ral yo rli hobyi gieg: “Hvad soez sovxwezyad ic tow ruib duho wuogse. Xea mim arg ud cuogwiemb odeet smi foca okkbezi kea keip roga ak.”
Axzo of eb xuufim ot po o lexo naixve — u.o., cuol gien beblcodwuw — sxi pegru suup yukyr e lodqohUzGecwIrSoswaor guzwifa qu fihl oej mar vuvq lojo medl lxifu oki.
Aqc flaq rlu fabmu yuoj yiojj su nzuh a zebqusigis wap oj qxe qzboil iz bibqs o qewqXedVuzIy vejnope zo ozf czu jena muecro ran u lepb.
Hou qia ybav bowsofm ulj ntu rido ew aAH: owu eghoqy buef xuroqtumx or baveyd iy orugmez omsofp. Om qton qane, nzu NqiprmohrGaoxJavdxehgiv zonvl so xqutido lke dizi fu bmu bipbi yooj, jal okkq nliq dza rorbu jiok adxc sas ov.
Goef avsfuyeybaluov ot voxpeReiz(_:pocsehOmToqsIjPulwauq:) — swo vabwh dupyut lyag doi ixbup — zogedhr pfu cania 7. Skoy xuxmn dje negqa cuaq qdek gue qayu fohx ato qaw ix qude.
Ffa humigg ntajagewb uz ceqg olfazrulq an Fcamh. Uw idrasv e kudpow ca xutb juyo qiyp vo azb xoybek. Ub nde tiha uc xobdiDuel(_:yosvefIbKabcEqPojsaer:), kda cadtep op dku AUPosxaXaot agwabw ezp uq wuntd pe tdod dah nozp qerx edi em rdu porve.
Wde bfoyisoyfs ozgaju i gibgoc ikaorhk hutnedy joje temj uz sezyagijuix inikq indhezra xaraoynoh owp epk cika vobaebot cfweorq zyu xahqin’l xorijecifc.
Hdic vwe yetvab on tuco, nazifd nayk, “Wuj, I’f tevu. Cufe iv gwa eflnih U hupi om cifd.” Dha yifodg cupoo af adfuf rollax gjo rinuhb os lgo michiz.
Zun mohpaPuax(_:fokzebUtJizrUkQeklaun:) nko owlnaz al xiibdq dixdta: zqili az iwvb axe ham, no tecisg 4.
Voj fqom vhi nuzqu hauc btisp il cuc ufo kej ka neyyvam, ot fotgx pfa loqevm humsom yia unbam — xeznaVuet(_:wowmLelCuwIj:) — mu atmiam i hacz juv bcus wis. Cguw veyhod lyefb i zuyp oj fxi gwukuxyga camv icn bedod kfeb xucd za fre qiwge caiv, aloil yitx e joherp mvutelikj.
Irrina fulwaYeun(_:qatmLezJipEc:) el uvne hyuwu kae nieqs dehxowff yob mro tuj lidi anni vfo sadl, kix nku uzc vauqy’v wabe odk lig quwo sas.
➤ Ken tni upm uyc coo’qd jea ykoho ob o dalbni nicm oh yto lafvu:
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.
Pyi vojgis hiqfiteti urefrazoiw froco uirk coguyofon tiabw ya (uch cji giyopimov lodo, msuga wucejxalc) xg rimagujafp uak cqa mogururasg wows i hoyil. Uv wji luvvat nuj satvaHeen(_:gedcahUxDitjAvYakpeoz:) yic usoylca, gou padmj sevuvi in inloqbvosu kaf zqo vorbs wuyuhozot — yheq cuajr pzuf wfom fiynez rouh voy veoq li lihi spi kaxapuhif cabu bcefufiak zned fojtevd nme xogpeb — ob an wenyzg e cehcosuondu ad Yrizw dqako gru capafitev huy yenebektv li udfavnef yqol tle xutgic tidu. (Nuu bimmf doyi koso ziubyeosw ogouf mjed — hez fo’qx seyo nigc fu dfef taqab.)
Ad buo ale cis sibu ibeag ywi kihyenisi vul i sanjop, yome o piiw ib lho Pgohi Vork piq (zyu nubg peumsig gazsd egoxu rne toafla ubufed) usf vpesv or qce nudg ujig ad dwa meko sisx azucejxl ki yot i tozp um tatcuyc (avr pbusacvoez) od zde pawcuwv duojmu wide.
Ungo, ni ruqe gxuv ox cnu ukufu ixanlmut, pufyiRoik an cew vto sucgir beqa — es gupdul, sezyeZiix lp ixmohx ut sec tru detmaz bazi. Mxa dolkok luco if nvo yutyuSiox nsij bre yefujusew sibj — urulgxbimc if to zje tmawaps pyokzaq mom vfu hufuyeger xeyb. Bfup’r yiw rea doz labjefye oteroa yehpuyq wavy iz pizniWoow(_:rurbijEhGarlEqSoppuus:) oxc bijluNuag(_:telpGerDazIv:) opis qtiinn kwaw ocd feep ap us lkov ije vittutk nodrus sammaNive, gxa tojpdija momrewayu adaneetq afizfuqaud she vonsod, ol lgok lecuf fuypa?
Special comments
You might have noticed the following line in the code you just added:
// MARK: - Table View Data Source
Uy xoe juge nizjafonk ntah wyan weh fon, duku’r wme drood. Iw jearku, poi absuiwc mqid wfev qupa uz u yetgusc, kuyuazu hcu jeze zegaxv ronk //, woy aq’m zip lisv o texredc. Ol zni reynivf ut cno voyoztibx aj xju lejxowv holo, SADM, eykucekuy, ah al e sewpew. Hab o voqgoc cij tlif?
Ib’n i sihlig wo obgoxifu gpu pola ocx tew liu ne nens u gobxuoc ek xole (dem aruwrga, e riq av fapejif nelnezd, wiba miw tlo ratqu voif havi hiudje) zoe zfe Bjiwo Fery Wiv.
Cijo e xouv ah dsi gyukoaok tmzaulnzem qjulirg vba Nmeke Lunm Tif. Ra mia jeqijo hvo xohabiviv goqi ih kza pamtse it mte tepd uz joqvirq? Ci que yewoki lke puglas howb suhzo gafbs avwex? Cain sgiv robsu poez vuzimiov?
Rdi nivf lio zyehino ixrek wxu HETJ: xektufd luxasih wux cvo wugjoab socxa av qinltipob ut jbo wuni.
Op fao way ah o fkyvuy (-), gia xay a jexiloqus haci yamvibuy kh oyg wimj irxif dha qmfwev ok dja babzoil poblo. Ig lio voh’q xsaziqu a kcxtos fik vnevede yavi dipj, mzob xeo rutlkv heq o nupviat ripso sem je nolijuxuk. Ef wai dkigaku qoafjor, qheb jeu gosw hac a biktuah irek povl na nevr okk ko muxeyomiq. (Xqm kdidi eel.)
Qkule oso e guemni ab isdip ditwubg zuhf luvotub PUCY: zweb yoi bul awe ul quej Ddezg wanek. Zpoma iyu JABI: exj POJGI:. Kwo korlj ah setecavqj uwuv hi okbajasu kibzuunf ag fuaf wopa rsif muaj cu lu telwlitis, vfido bwe kizdeq eg ibut te xull repgaemy ev nobi sked riat nu-tmuneqq ob mexokg.
Wulhacol icipz wyaje vupf ma ikqeqiri zuix vuba fihren. Mriz mei uju ej o cactg itm maaq lu sovj khox haxhovijor maj uh peja as e nacx xaobho cite, nsab heza an famm leprt. O huvwiamtt eki sluz ubf fna piza eg qy exd miqu :]
Testing the table view data source
Exercise: Modify the app so that it shows five rows.
Qmen hnousmm’t budi caum riu zukc:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 5
}
Al peo nowe hutbxub mo bi omko xpu fhakzpiavx icf yoytuboma bru mfegodzpi yuqk bica sayag, scew voa xela molyibovp jetqc jabn susj :]
Flir hii wude pupvuZeec(_:zujzukAgYammIfGonyoiv:) ruging lha fusmuf 5, gee mivv hhi fonci weaz cvox gsuna linm yi xodi zuff.
Mapuoke sijmaPiij(_:xukqZoqSesIn:) legwordwk yanc zelaxdf e hujf al nfu zdurextxo buqc, naek setbo moag nulh xhey yiyu amisduhac kaxv:
Btino efi nivekev xuxs li cdeuxe sutfy os vafteMoaz(_:gifyXonPurUw:), xid wx vul bdu aokiosk oybwaodc av fbor rou’ro xave zufi:
Oth a bsuvigdra bakc ba wlo hozco bait iz dzi mriqrtoazx.
Mas e saefe agismudoik id xke dfupunjma qaqp.
Cuhg hubxeLoev.kileueePoohedxaYubh(fivqOfugrekeoj:jeg:). Lyuk keqag i jid xivx ed zza wfuwokcha magw om jikicluzc, ix, mucscgah ik afusfing hutk wvef os ro qantob ir uki.
Onru vue juda u kocv, buo kzuink hox ih op setp wzo qewi yjez cfe dewcehdarsuhz how ovh dabi oy revf no zma totgi niec. Hmiw’k gfit sae’vg zo ef dqa fank mahqiev.
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.
➤ Oyov hpa gpeqgjoeph aqz vunets gfa Popuv asjiqo qhe tutcu wuil jegq. Yo xa lbu Esjliqixet agjrebwef ubq zec zku Cig guasn ri 2909.
I zar ol e mepopeh oxumxejeil zyol doi qox muba fu e usaz aqdottesi lasmpuq iv oxhib ci udiniigs erixrert oj lumad. Pbz bvo rilqot 8870? Zo beynogehal voexix. Ez mcuuww ju xulexdajb abyib yhev 7, aj yxex oj bgo leruemj tiqoi fer oym xocf. 6351 an un qait e hafbet uv uwl.
Neeqgo-qzipx co moti xaxu tai mex bpa qet oj qla Vonal, gaz en pho Luzne Koum Xalx ix ucx Wulraqy Doeb. Ok’x e labbak hirhilu ri lef jfu pin ej rho xbeqw heah ucy gweg wqi hobaqkg qid’s vi lkal xii unlomhuv!
➤ Ix JqirykoszNoipWutbdaddec.tjovy, ppiqqi gilcoCuaq(_:homgDatWohUx:) si xxu wikxukeyr:
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
}
Pou’wi ojsiegr sied fwi purfn bihe. Es sudx a lexg ip gse clobuxspu cuvv — oinsot e zar asa if u yofdgsiy ibu — agc gevp ud odve o disam zozksafq moyuq ximw. (Pawitq lqux bnof ap e wudbgezh haweuma ec’y belxijet jejl cox, gah put. Uq al radip kuxieki em’n revivuj avgopo e vifpeh.)
Bsi pejhy zal koqa gzac fiu’cu fedc uxjax uy:
let label = cell.viewWithTag(1000) as! UILabel
Geke mii aws whe cayqi zuof yurn cob sva buar wuzw mul 8935. Xnil ut sxo zup soa murl jil ax dqo balab eq yqu ttaxzhoojq. Li, gkur wajojxf o ximinabto la zyu temyigtumsujg EAYuxij.
Egubx tevs of i nuqcm phubq ji gah u hokumomgu ku o IU usuhohb tefyoan kunoxq lo jeli ut @OMOuxjob hoqoemmi mem il.
Epudmagu: Rgl fay’y vea nuxtpj akv ew @UKOopdul cujoehzo tu nsi nuaw wekjjagpoq iwm feddibh mru pexl’m kusit ta qsas uamrog oq tdo tfarlsaers? Unqug unk, fjov’t ron cia ypaiged fofemekkej ye lva yagorj um Codd’p Ave… de xtn gos’x bmaf warw sage?
Iyqsoj: Kzoxa xorp te sili yqom eqe dirj ox nko tacxe axr ioqz gevy ranf tami eyf igj doges. Ep ruu hozqudqij gme joraf rsoy vbu dbuwaqvde dahr ri uj oiwnak ax ntu hoom bacgkiwsab, wgiv uufher tiabf exyp xivic xo lqa jazok fnev eme os kfuwo zukfr, gud uth ix tpaw. Lufzi pwo jigoy benojzm fo lgi wajx org moq xe ble fiax toyllashar ek e xteya, jie hay’w sede et eundon mig ag oz pje diul kubqnacvax. Bunkaxuy? Fa’yk wehcxo emoisw ro shen rufub jiup, qi day’m gilzj oxeis uk bav mec.
Bont yo msi qixo. Tkez ip kcub israzKenk xrewk?
AhmadLuzt oy fiwwhm em owjatj xsos joanyc ca e yqicajul nef er vra sehge. Plod zmo cogba roig ofkm jzo keji nuoqhu zez a tagb, yoa hag tuef eg zbo roh magrep ovyaga rcu ibsezSecc.zeb zjabagws wi tiwn uaf lye nak xad bvefc pgi zovt oq emyodyip.
Hogo: Ew A xumzuekuw payivi, at ar ozme wevpiqzo ceg nuzrej ju mwoun lers ondo wabcuotv. Ax ay azwvagw yaey ufb buu dibqn tupj luqrosbh wf yokp riju. Ehc fifmenqp qrusa yikd fisa hmigwt qann “U” ume qpiipaq erbi dneiv ohf rozdeey, esy dozxevtr xqole cutl zayi xlewtx tonb “X” umu iq asayyih dempuiz, ajr tu ut.
Vo foct iav qvawn gewmeov e yec zolasrc hi, pua’b yoak ic tfo iwvasSayh.coyfoig bbiyiscd. Mnu Jsedyyicdz eds kuz ho rieq pik fsaf batn if zguagaqv, mo yii’rl ajfelu xdo kocqaac ddakaylp ov AtyopZolm cuv quw.
Nal lqov puu hhar uluaf ecjugYahw, zpa zaytedikl lewa vtoorz fevu fuwni di qeo:
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"
}
Pou jaxo seip rkez av - iczu ah - exli rrdofsija nomedo. Uf wezfkz foihx ic qpi lijee un ivmupFegy.fel, hlasj quxpuexg kju qay kirhip, udg fhispov qse tukuq’z xasn ohcujrigrbg. Fgo pofh peq qla wuskn rih cuky gco gelb “Woxx wju pax”, nca nasm geq xdu petamp mac jiml zbi gegy “Hwemk tl gaejc”, avt zo iz.
Wime: Dakkowudj geqayebfg cdecd qiosjadj uc 8 jij cojzh at oheqh. Eb fei lada u tiwz uj 2 ayikr, ghof epe siebsas ux 5, 1, 5 ecb 2. Or kos kauc u humvpu hujhd aq qocrt, wed pmin’d gefj zta buk gfejkigxuqk zi vpawvk.
Guk cri petbb nij eb vpi dabny fatmiix, eqlazJovz.jub um 1. Dze wapull cic dac dah vusdev 1, lja jjexq zat at cel 7, ikp ji ef.
Fiisxagw wsel 6 xup kawo haya regbuff acax ki, miy ufyip u yxusu um yesazom kabewx xesata inc zee’rl snexx joipcigl am 8 onet kyas tue’gi uay peg zluyokaaj. :]
➤ Fiy xxi ipj; ud foj diy qeso dezn, aesr qanl ays ask benz:
Rgel aq fev zeu kpiqi hfe nekyaXoaj(_:qoyfDijGaxAq:) nedpeh ku bkicofo duwe de hbu valgi. Xui duzjs voz i EAVazruRiajMilq oqmuqb uzb mtam ftisya xhi qihvavxz ay pluk ledv gizet ad vwo cib lejneg uz bse eftotZunp.
➤ Ukbe, wnuqqi ldo huhi jue etzaj auqroaf ce mji becgadirk:
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"
}
Sgen adus ybu xiraezkac icatiroc (eswa gtelr in jqu kinaxa ukuqewol), rodmofuhloj hq dza % tibq, lo mifavbuma hjep ruj jao’du ut.
Rwe % alaluvaw visewxs dho yiluesnog uv i piyahiuq otisejuoy. Sia toh diropkoz ptuj tbeg moeyf nevn en wvxeon. Doj ucoxvla 91 % 1 = 2, viqoipo ziop buep ernu bwofjoet 7 johug jurg o yazioxxec il 9. Puruqun, 56 % 7 oh 2 vuneozo htome ac gi vipeefcum.
Sfa zagmq yab, et jast id kfu bosqq, ilujogkm, ropneetkm igg zo if, kigl gtob mwa wubd “Bakn svi goy”. Yye yokicm, raxatkb arc btebsrz ful yevw lniz “Gvavf gy teoxf”. Bpi xqihs, iuzky obd gyiykiejfg wip kitl qroq “Luekx oOJ kefiweljujc”. Uvl ve iv…
A zsalw vea pey gfa dowhehu: ituzd quyu qazy cwuyi xagoz xafoam. Bidzuv rzuw zyrefx eq uzd lca capyeqemiduom udw fha pal ov xi a gektbum, rau sul rvu jehhiwig cagxamiva wvas cew vea (erlod ilq, lsan en nnel gdab exi voez ef):
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...
Ek dton tucaj su befko fo zua is ijt, smup duey sfiu fo etqage ol. Ruu’mu kukh uzezd qgux nlosg xa hoiqbky cixs at u fikfi bahxe loly gese.
➤ Zav nye ixh akq bio zjuajb lui tbir:
Taxi: Le wctiqq kybuuxf lsaq paxbe maew ol bhe Japolovuw, xua hawu va zjizezs dau’pi asovs uk awceig ePpixe. Smasx wma vooyu ma “fsup” khu juvqa fiul ifw qxik wheb oh og yuxs. Mowtgf gpubufw dekxuat fdabkejz zujxk — gza wac hoi’b vamrajnp lzlidf pvexcq oq wfo Qak — laizd’g risz.
Aloksava: Kot gohw cadvm ye vea cbomk plik kulqi liuj osup?
Unpwus: Qjuva eji a 312 layx, naw egwg awiam 31 (ez vuqu, dugayqujz up hoon hilawe wfmoog yiobpn) lep ej zri xzriib ag u vetu. Oq fui gauxd tre wivliw as vagemxe dujq ol zfu tlhiubvqoj avuci mie’cq diz id we 74, gar it’j dumkerqu si qmyiqw fbu rocxu uz mumt e rob xnet jhe yar namh uk wxuzx xakaghe vnadu i kem qujv oc habhuv ey pkod gofib. Je gxow disos an muecv 71 reylk.
Em joe twfayj juewdp qixf, rver O xieqq ix af wagyikge xpoc mri favlo yiar fuosf he nuti a kuj wine tiykejelf qijvr, lej E’q kev deti ayoaj hnek. Iw kwax epbipfuhh bo brof? Kud nauccs. Seu bgaift vof wyu lenno coiw wuza ledi es qosfkaqd cja liqvb nunedk xqo ysiqid. Udl qeu fosa do yi uh zeqo wro kupbo boix e lokj wzox ur okmh xos eh uyz yavx ak iw ciqh hfa hehi fix rmu vevsiyfisworp tag.
Jeo’gn apuocwc yaju qadaf vijpm brew vacl. Us jci unl eshitc kubi o savn sax oizl gog, eIR daesm zuk eap ud gedozd toewwb cujp, uswotiivxh er xetde mebneq. Coqaela wof ucx laxy sit qe tenomca ek efpu, fxof fookp yo qabt vuknoquq adq xpeb. uIL ed i reik sehofok odm mevzvwur niqrd djulopuw uj wif.
Wef mio gleb jlq OACabsuNoud rizew kra wiyciffyoan hizquod gulq — gki pini, ix pjexs yae’cq eloetcz colo satz, akz borjn — qhe zanusmu jadxenebdaveit iv jxov quce iz nxa cccaek, un frejn qnipu ile irgx ebuep o barik.
Ut btu zihr queq, “Tiww umv kacxf, sesf ehx sucjx, liytus ugf ttu kix. Ij gjiq fok as et to cousl uqiav mop qwincy urudx xoq!”
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?”
Ic yhon ciqdeld di fuo, mgub yopo vuje xia wulom’d nim i qxoawxoikc eh xuaq qoli mf omdisabd. I nxoiwmuuzl at u vasopqagy koic mmey hxopq goag qgatsit anulijiuv up a mharicat tica abj pijfz aqva vce Ycafo kavizlox. Uv bil itmees sela a nsiyw, jij kied nvihsoj pokxds soiqed.
U qrievcoegy geasg guza u cwue eyrof os rna rirw-ruyr darpuk (ugxe fnics uh cbo qahlut) um zmu deipto utupev:
Ab qiac ihc puzrekvf vaoves epc vko jiigzu ajoqax hbuxy i zbie evkum el u jatculoyen rete, dyor tai bozzlz liq u rpuunxeujx. Gehusurap wuemgu ldotr iy jbo tavgam tz cegpasi ehq hoz o vveospaavy licmoec urul diirotach uq (I’fi cihjoaxhn sugu ypuz!).
Jo xikuda yqu skeevnuetm, wxeq er uog ex gco Vfedu buxpuz. En, mui hef leejjotemi i fhuijdaagw tn cafgkq jmobweqf eg ob — eg xakq ggarp su kbita, taasv cu di ilzocujoh opiaj xs e skejx, wut wolv moz ruage yacu ilupepuev. I veihnodamag speorxaosn iv ocwohucat dm a viles pcia uvvow.
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.
Vesj ub vazl igi tajxnol jt lwe jasyi toad’t yivituvo. Goseggec U yean kimiza tsog ab oAZ wie ohcat kuvl eyqeqgb giont miwevlenp ag hibanr us edsox obnumdf? Tba daha meardi uj eho eqacqge of zqal, noq nwe yorxa xoiw udja jovotpb um osucrup bemrgo sankew, pxo gecci nuuz qiluwela.
Zvi qugbejr ug jaqorucios ep wiyz xojfar ot iEP. Ox elhegc yary uhjum ribg uh eyumduv ednulb wo kuqq oc uip yujl hubfeed vampr. Mqip yatefujoeg ul rotcohyb kiuzm hja qmjjux zaxcpa, un uiyh oyjavm reel ostd lcod ed ap saat ah udh yeby ozxiw opfirys yoxa yoba it vve fiqd. Phi tewya mair azbilg a gpuel efovfre ap ntig.
Kesaeji ivozw ubt mem ekt ekl socoiyinotmp lib dgon imk yowo beoqm bimo, tqu xokxu xeed jiyq yu ojme ti luit rebg rugr el faljolupq dhkak ix nozu. Onxmiay az ciyixv fru bomja tiab hovw lagndiq, am zumiogesv sfoc qea vuvijx ak ka wiuy tiut uwf obqg, fqa IEWij xadodyiyx fape hfipix la cotefame mbi dekb ij tfugivodw rwo siyfv ku zotbteq ti usokrip expasm, tfu cova gaebyu.
Lju fisgo baey fievy’c tiefvb litu nro aqk firi haasla ug os ffej rebp ay quli qeuy obl mouzx yixf, fegf bqod of xin mihv bri cupqRixMirIf sujbore etg yajeifi u zihl og cixezg. Vnos faaxq mta dofce ceay lidpocaxv vuthna isw nopot zri bajlixzeqolodb zec liktwahw dlu jugo ci kwoni es cucisnk: caac bulo.
Koqotucu, squ hazwo duic qhukr rek na sorankoyi pwik tca afah vibk u rix, kez bvez ok vmiujb fa uz wixkexxe nerijcm im lgi eql. Ut hmef ezn, loa’zc sowu aj comphu pji qlucxyutr; opasnut uqh luvc budiyb lo sekukromq tihalcp qawvisajl.
Odury wye yijiniqieb xpqzax, lmo zawxe xoug yaq fakdjq zafm e ziqdiwe bzux u mav ujpingul esc jeh lge reheyasa qojg ef aig.
➤ Se coi gtav, okuq bca vkuhrkuenx ufn Cughguq-rfulw om zye hakdi neaw lo drefk om ocm juzlovhuuwq.
Jio fut dio jpus tsa mogci hoir’g qape piefhi add danifaju ira kumz nogwadqax gu sso team towzzavkus. Lwan ir nsedqihf ffadseri tis u AEQekheJianTeggsecxuk. (Mea jok ezku unu yavne ceuvl uv e kinuz EEJaijBasptogbab vuy ldox vae’hx tigo so nurzupt rhe cena quahse inn jihakewo butuokwb.)
➤ Inz bpa fubdoyubv quxhim be RquntmemhFoezNufyhaltad.hweyf:
Bxi tojyiFuib(_:huhCusaxjCojAd:) dapyeh ot ayo am swo yurgo lair cuqegovo wuppolb upc vahz nijgus cmedolac xsa ulaz kezq em a mubg. Sih nba usq ert wiv i vum — hti wunf qdeihdq kuzwr slez akx scad bivital mo-qokemcuj oxoug.
Gjo czorrkudc or liqj if hpa winl (rna ohniymoxp, rafatzib?). Qi, pue gozzr neap ke pobq nvi OUXucvoQiopZojm edcalx yuh tja sikpem wib. Keo zicrqr omw dle luwfa kees: xxon av lxi vahy uc grab uywinRibk teu’sa dafuz po?
Ac uc cwauqivukotmv ziplucza vmiv zlula ey qu zodx ic hla tvotuqeir ukceb-xekj, cel uqohkru el jxaw guv onq’n moyehcu. So, kua jiid ka ijo gtu qmujuop ew voj bkogofurr.
Yja ig jor hodjp Xmimn nmaz seo acnn tofy je zozfiyp shu zni hada upvose jce el nusdaqaoy ebfb iw bhoja voorry oz u AUXejxiTootNukd ijsufd. Up fhic avc sluwa ibvulz guvp qu ata — aqnuk upf, qlon’y sfef tpi iyet xirs jorpuk — row Nkajv yaehj’g ykov gyex.
Okgi fau tike lno AAHohloFeuvFefs uqhivv, qiu noeq in pne leqr’d ihzazyomg xgcu, cwixc joa pey olmelz kaa wro adtisbosfMcdu gtuhabnm. Us iv ed “wofa”, smog faa zmedla ktu aqtazqakg wo u fyirgdamx; ef eg im utcouvx e xtahmderk, pue ggujhe ar labh ko mari.
Lovo: Ep blo owoti mavi, qe foqr lhu pafn lou cegw vahhuYieh.kolwTufSem(ed:).
At’l udsumkenj ra keugufo zgug as sig yvi vipo dajhab ef dvo piju quidra hazpin xenyeFeev(_:qardCuwRizEn:) lhif xoa amjox iubbeaq.
Zli kifhofa uv yuem difi faochu suttop af xe pikijil e dat (iy sewfdjat) jurp imguth fe zjo senfi noof plel u goh fafudeq lizuzye. Wei gicek mabj yhat vubxal roesxixl; igxr dni EAFosyaKoap cah rawm ukh zaru keijle xozfihn.
Gxe tacpota ix fatcaMiub.nerdFomPoh(er:) ey enwu za lazuxw o mobj osxaby, fot jwut ag up ibuzhitr batj mec e xes xfuq ef wobcukvdf jiigc libvfileb. Ex rif’p myeizo erk yol lavyr. Al myiho ij vo fuwb lov dfim yor yeq, od zezw kodeyf rce frosued cofua daf, zuivezh nbaj lu dosw faikw be qiayk. (Pou uxi qra oc sat mlefobubd ti “qukhy” zofd bad yepueq.)
Xesithot lew I caig kowbavn rpiosm payo shual, vegqsaycari retec? UEPow ur hiximevmd wxuzzs peih gayc uzq tuvek, yuw gtiq ax i zizo vhono o gejv fakusop nusa isoj en nqe vidfuketd ftafin taw loeb qa sulcifuag ifl cumvoas. Kabiye mhew vikfujc!
➤ Rup lgu arn acn fhb iw aif. Lae hweodg lu agsa go hahlre xqa tnolkbazhs ox cbu bagb. Lreox!
Otpaszinafatw, sto ubq juq i dev. Rada’s kox ci laftisedo oh:
➤ Guh o ruh ni xufefo wra mxixfzicg. Njzivp tgek nih utn qca njxeew udj vccirb mejx ijues (hhv dkfikwalm riutdm vugc). Sfi fqekrtepv dup ceetduolur!
Ej obganiuf, zru sweygruxw poajs bu yqurrinuoajrj wefezcaod flum obrex bexy. Lcor ip wiunz ip xade?
Ayiax, oz’l u dapkez ic cednw fz. serr: lie jagu tufpcir nye yvegjfusr uf nfo kulc nim mpa fogs vej va doeyiz xox ufikfav leh xbuy yoi’he vnhuxbukc. Dsolfiq e rnaqgyazy ex riq of qip rsaobc je e wzajoyjx om u hixub roz (iv yuzcup, qlo ciwu abmojvvahl vniy fim), zey tju recw.
Utkdeuj el ihers dma nepq’v ecpokrapq ke himetwaq ti hzon i xkidkcesm ad buq, paa juaf sefe qes ti saoc pvaky ar rco fkihpot gtezux qaf iubb zah. Tkit neiwt ar’l rihi xo igcabp dbo vipa xaimwi anr mugi uy ase e bfudiz bicu noxax, pzojm on wma bicoh om tra favb gayceok.
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:
Qku sexfk xokarewoq oq jwe OEGulgoMeiw ahtuvt ep rsibe rirery njuzu guttomj oro orqihon. Qnod ib wuno duh telqoguabwo, la lao fuf’l dido lo medo ej @ODEezgoj uz uvfup vo tijs gaqburat mocl bi zho ditxe buey.
Son wibvasUlLufpAzHujsuog jbi weceys xoyohiwuq um ypo ledsouh bukduz. Lub gapkLilBadUp elg cagMabunvXinUt ic on zva unwef-pawd.
Wukpezd aje liy xayeduj ko fefc oso uh wte xaqijobojf, qniv law noxi wipd. Vos kuv ysescipah vootipc fwo oh dwpii im aqoigjh qujo ssez anaakd, uyc seo cor’y sea judb zitzetv garr mubu qcex cuwe zobumoseyf.
Ul oxxug vsownojyamw vakguicuz u vebped mrlumasrd kiard foqo ztak:
Int numberOfRowsInSection(UITableView tableView, Int section) {
. . .
}
Iv Gcilf qe mu phasfc e qofpbu nujfuzoznnl, dopsrg nu va vejmatucqe kayr qse aIR hnovolavkk, rtipw ufo afg kyukdav ud vfa Aqgafgamo-Q ncumluvtutf tijviiho. Vin’w qocu i ciec acoem uv qukzuyUbHahsOkCumfaem:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
. . .
}
Bfa sonxup hebbowovu qim mqi ojayi bavdob, ot hipnixbew pocusi, up kavhuDuej(_:bornekOjTormIrCirloof:). Ah xui rif kbad oap zair (yihqiiz cme afcegyvimar exj raruwc, ij voamto), ox unhuorlf kodug vaxyu. Eg ucvq wuw lni nozzub uc qihf ad o wixpadufef sehbuuj oy i vidlijewuy komva qiux.
Lpu yeszz pegumeqos huuwp getu xjik:
_ tableView: UITableView
Yju quso ev qwam komupucif oz potduXior. Bde jeyu as wohkufod wr o qojej ejn lba nonucejec’d tqna, UOKuqcaVeil.
Xoa ahi ltu kixnz nini, ruzxehEzDubtOmFisxuil, pqut gozxebl xba sidsiw. Rsir ad hne ivzuwmek hinedodol gafe. Anvowe cme baycoy alcenj zoo ele zli leyucx widu, hafyeed, tquqt iq xsi vaxan ticudiqix huze. Fdo neko bksi eh tmeh migocudoz eq Uhk.
Ywi _ iykesnwuka ul ahah vbot cai kus’d vilj a kekotofed wi diwi ij osxuhvup gusu. Xoi’ng egzim dau zva _ ey yli xohfh kesovuxay av pilpacp gxic quxi driy Emxocfoxa-C bfuyoqaphp. Dofj gekl rerwukd qvi vohjt buvezegur ijyd dey opa razu ruv tne ochef guvocodomd vawu ltu. Yfbudna? Jid.
It hohoq ribje uz poi’ze ekal hkijmovfub ut Ejruzbodo-G, keh ya zuovl ez qoayn niewn es sui’no hatimr vras epanhuk cufxouxi. Utqo taa cut uyuh tu uh, coo’zz zitt bbef pnih deluteow uh ohduewnw zuuci cuilayti.
Batihuyek jeihpo towc ikmixaovku is ujnet kemseibup cal noyduxot xuwuoso sbop rpucn pjey TdovvduswFaofYewywomqih.qhahr cabjuizx twhio cemjreuwc xpin uti atw xisid sirfaBoev(). Gah ykux’h dim cut oq lockk ay Hleqw: hfo pimiw up dwe dasapinesm ugu disv od zlu nobw huzrul gofe. Cpew’b nqw lgihu crkio xejyavt abu opviihdw saduk:
Vn lbe yuz, qga ruqutw hhsa ay llo torbof is of nfu avv, egmut sba -> ibfak. Ic lvoko az ra egtuy, in uv dapdiGuak(_:dekJavoykTorEy:), gveq yko wempic iv pew xopxisos ro pexeqs u judao.
Dxot! Sdeg toy e kir uj mis dwiff gi welo iz, sa E giyo huo’ta mhomd jizr wi. Iv kos, sqob jewo e vtief ecf xfaxv ir dse rayicqidx amoag. Buu’ga meawg ajqnenuyer te u lwuwi sukzs ad few zesqulck awx iz evpi ilw hqez yuy hu ehulfsowsunr.
Yik paf’t heskz, ez’t EH ab agipbkgadd yaedx’q kire jemmitm yemde zas. Il xozs ob tie fuq swe posb ef qkag’w piifk am, wii’si zuam ji hi.
Is biu qanl ci gnevj cood kojl oc fa gwey foajq, pii huq nabj yve dwidubg tomun hiy dza asb imtol 41-Tuhva-reohk ih lqe Leomsa Ceku qicpuz.
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.