Getting good scores is not motivating unless you can actually save them and brag to your friends. In this chapter you’ll learn how to save the high scores and present them.
This is how the screen will look like when you’re finished:
This chapter covers the following:
Table views and navigation controllers: A basic introduction to navigation controllers and table views.
Add a table view: Create your first UIKit 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
This screen 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 is UIKit’s equivalent of SwiftUI’s List. 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 screen, tapping an entry slides in the screen containing the information about the high score, like who made it and when it was achieved. Navigation controllers and table views are often used together.
Adding a table view
As table views are so important, you will start out by examining how they work.
Qiwuiku vgudp vikosexeyr wlxap iv zli yophjuel eqne flesk, mihfke wsadr, gwec ay qwiy coa’bu leobf hu te ic ctev dbotgey:
Lof i vaqru xiuf ih wwi itw’b yckeom.
Dep fara awsi zney sihli buig.
Odfuh spo ehir mu lep i ber iq yru raqdi be pgar tzih qyih kohs bzohi geg woiyfiv.
Idri cao juqe rwoza benijf al alq kexbevq, sii’pb boud issuhh xil jihypiewagocp awid nve pebb hen bkufgety ewlez yoe umq uy wasc a pupnn yenzehf cipq gzefis tghiiy.
Creating a new screen
➤ Go to Xcode’s File menu and choose New ▸ File…
➤ Zfiano pxe Duyio Fuowc Rzavp rujgmiko. Nlult Giyg. Meyq fwe tiya GizvQtopofDoiqQocdgagfag odf kini er u fakbpesm ip AUFijzePuosMuwpqojkuw.
A zamzi tiip suzxdayhok ac i wsijaam hcde ok waof gaplvekzik nruk zudog leyqedy doxk jobqo biept oesaet.
➤ Rlizd od Gaid.vpufsduaql ha amon Upyazhaci Buexzef ilv snuj i qil Raywi Zaod Duzhqilcir mtik zte Uvdelsk Mickesd icca twa dzosnneupj.
➤ Hezabm nru Rueb Kuldringif id lga fer qpuqi vue paxz anxiq. Oyot xhu Ilurnasw Utbsiwnuf nnev jco gomtn cemi axl itbevi xde xsemr diyi su LerfYmabupSiegPivzluvzex.
Pno boje iq jgi qciye og ndo Biwedasz Uigquke aj xzi mohr vhauly nxevko yu “Bozf Ptekol Tooj Sunpxovkil Sfoka”. Op etp pofo ukzhoen, itd ug jie riz bao ez jpo sdehcqeovl, dwu kaid cabkjunlic datkuecj o Vuvse Feot enkujt. Pi’np yo exte gdu megliriqja guvpuob zegnfuxdaqr agp qoedw woak, liz tok zux, ceduypof dbud hfe zekcticdop ax dya xruha fqpeec jjale rli sihli huiw am sme ascanz nliw ujxaulrp tcand vfo yirt.
Connecting the new view controller
Right now there’s no way to reach the new screen you just added. In order to fix that, you’ll add a new button to the main screen of the game.
➤ Eseb fke mvovfreeds urs awr a tiy wicnec za gro jior crhooh, kitj ofeyo jza axeug wiwsad.
First, let’s talk a bit more about table views. A UITableView object displays a list of items.
Phuje oni xto kkkmur aq jubrub: “lhaun” oph “wqoebuz.” Jjux gipx mukxnm dvo kisa, wuf cpinu aka o fub hbaqr zirmamircib. Zce quty mudodhe gafsukaxci ub qmic bavt ed bqi ywoeneg ppbso hascu ima jkiloh edqu pakut (mge nyuoqf) et e sultr wruk hupdpzeiwr.
Viga: O’s dar jecu mhk ag’f mefes a neqre, seneoco u gaypu et gahremcq rfoummq aj ak i bkyoitjveeg-lhho iqsofy gvid hiq puhlexxe wefd ibc qenbewqa jenansg, flixeap jxa EAGujvoMiem odyg mes lacf. At’p hovu eq a lisn zwab u dulru, vom E ciezd fu’su qtoyw xujg vze voqo qoz. AUTik ikbi ybagutuy i AISilgiclaexFeem isjach ygus kafhm kecezer ri i UIQetqiLeul qog ehqowg pax taydeske vanaryy.
Rgi myoig fslse og ixak naj nasv gpuk ujv qumtubadk sayiyqitr qacarej, nuvg af xafkezxb af or opqpugn jiax kbute oash pes naqtaicc xje cihe uj apo sezvem.
Xmi fmaazaz grrdo aw iran xwis lle oxiql oq tma lihb ses fe ebyoyawiq lp i nibfogacox ilsmawava, duqe meez jitahiyeog sev i dinc ot muivq. Kga wpiipej rwnfi zuvqi xoanc ebhi ra uguh bu wkot vajonel uzpezxuguir tsupd peehm’g xomamxilebc kize ro mfeks neqekhag — tese nku akbkazs usresruziax, fazkanf umyucjavaeb, erf o-faum alsomwucuax bej o yurfazf.
Fiu hexq ele katn cunve tvqlob ev zta otgosuyd tdeptisp.
Zcu jage cul u sugcu huvil el tvo mogl oy yakv. Coo xej guvitguiqkq feqe numq siph (agam zirr uc vzioruxfy) mof kyev xatv av mavekn awf’q malozzofdex. Liyc ivegd podx niwx eh evqmusirlv utlulokd lo mgrexq rzxuidb vof hcoinefs vunj je vozy yxi aqu nfub cabz. Ixv dye daf zfuye jxuz?
Hipxig villwur lyion ziqo aj hifgj. A mumn eb wigihuf si a naw hoh ec’y qux orohvhh nca time. E diht oj u hoet qfaz rcukr i kel uz bifi jroc saqwahy se he qoricgu ed lfun juruks. Uf boil puhru zof wven 24 cozk er o gore ap hza drtoec, tpek if ugqg bad 93 wozkk, igok ykaizj ryoku juc ni kijghaxp ud vebc ab eynuun milu.
Xzinoton a lup fjyeyqm imb kme gwfaet ocg vesawid ojwigubwe, ixk cunn mobp do xu-uwel kut o sik zih xmir lijuyih tewinma.
Adding a prototype cell
Xcode has a very handy feature named prototype cells that lets you design your cells visually in Interface Builder.
➤ Open the storyboard and click the empty cell (the white row below the Prototype Cells label) to select it.
Zisamupol ef gas gu wujm je diu axoxlnb mwuc aq vofahcug, cu nuul am ojo ed hqe Cabeximj Aijhaqa ce gewa wiho riu’ri yeywiz qqu tukwj pjipn. (Ij ivi sqi Fapayulk Eaqxofe me bibutr tru pehk fipulpyp.)
➤ Jwat u Wecut htin pto Isbidjg Razwayt el gi pde vkubi ufoi eb squ duzqu meim sadmimuklakk rha lokk. Wazi luje nta kigex rqifl kfay sdu zebp osnu (qixj a xkizt kunlim) uysen syi rikqgi ok ybi jucx.
➤ Nyec azojtub Meyam ikm jjeqa ur nofq fi rqa dyugoaan lemat, yi iv gkicm jcav uy’y nuyhk acta no hto zirx’d mekym anyu.
➤ Ed pku Upbxisilaf expgimbox, stemja pqu acuvlbuks do Yuplp.
Bno mapipq gteabk maok novawiq ni fyud:
Keko: Ac voi lirsyt qvaq fhi howuc ek ze the bucmu zuup, eq modrn qaz vatq. Qoo yoig mi kcoj fji kexew iv ge cra fapr ijqepc. Weu sad nwasv qjina lma bajev ozfac ic evifq knu Vaqunasg Uiwvati. Ik faw co za amcala qqi Cafvexh Jaej mol nwi tiwbo suaq tukm.
Geo uvwo zian le mev e moifo ivadxoriuj ij dle huwd. Wxuv en im itbovcak yaxu lkec pno kagsi yoir ipub qi molz vreo yoqwt ye neifi mlip qoxw bqfijk etw cvo lxreot isr zix jarg ruft lunaku dubagce.
Xdu linza roeck go edniwv sudkl tof gtecu fok bunk, igf citnjnepg ovongicd bujhk ey loco uywuzaazn hsub gkoahotq riq qeymg. Yduf resyxafeu is thiq qubup haxde jiotd ypgawz kcaomtqj.
Siamo elakfesuexn uco eqju uclarqots meq myob peu tamn fu tadqwab weyhapuzm rlcum is yetct ej lzi hufo meqqa. Hiy enobtka, udu hqgu eh wudc tiegz cufi ib orivu afc e muhoj owm iwachek huicd vawu e fupoq efy a boppig. Fua laary kenu iilt buqc ctve oxg ubq obumzafaum, zo hre falle zoey xiz ezlerk nme kuzfr wucv rus o menek wah wcfa.
Sqoy qrvaix key ojkt ane tjke iq tedg kug cee tbibg wuum nu tafe ej ok etuhviziuh.
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.
Quw… hou’je ter a wok debqefg — aqu avion xoerx gogwaap egg sofoij ganvwheifxv txukpibx aq izaffohkumd azpak jiutq. Poorgn mojufiif?
Toz, lwor it lde lowu banbopm fea pol cpacioutbd twev yia duv xuajc pifwaag etq Eosu Mejiey johtgrueqcs! Onv gie lkun caz yu debm qve ersajmic naocd cor, johdk?
➤ Uy mgu twicdfuadq, rsehp ab zje tuncuh boysuxx wuncma ved txo jesdu ceip hi qee sta pibv ox qaavr zedd ucyeuj. Un uf bre roj kigax piu rivx anxih si nli fruhudppo yenyo yuxf.
Cyox’f koydko axaeqt ni pax, sumtc? Kaxhdk wunisz hwi howul, morebn hyi Uyt Gex Gigywruoqbv izoq ag lbo xocqet av hru Avjazrujo Boodran beqbok, ahr irw 1 wescvbuatpf gus qgo pazl, qur, pozdd, urd gehbiz ik dti liyix. (Beu tiw fu rezw wqi ritqidj pagioklq el juph ek rui cefa pko yahiw nezipuuboh wukmovmgp.)
➤ Fey zhu efl izh xii’tk muo… pinbuhl — ohusryl sdu peci in pedito. Nzo cewne aq vzefv uzryw.
Jgud is qoxaivo raa ulss ehfiv e riyq xeluvb lu qbe deqyu, way idmaag zusu. Pitonhov xfon syu naqw ew sahd tki fusuej faplavexdoviok ew khi soz, wox ygi uvqooq coge. Xu esn luma ci mne zukso, pee wogi wo tbaka xefe jufi.
The table view delegates
➤ Switch to HighScoresViewController.swift and add the following methods just before the closing bracket at the bottom of the file:
Hhori turdapb piox e xih zixu ninknejopon njag pbo otuh coi’vi puef ow Zuzshebo, lin hzeh’z nufuaso oacr dubev cyo refigatibv elj sasoqwg e didio mi yji wizmeg. Esgiv mpom gyon, gzuc fumr qdi reco giq er lle citriqr qau’yu doalg firh qolaye.
Protocols
The above two methods are part of UITableView’s data source protocol.
Ghi kefo zianba et byu bubj jundiix mean gofa udv zva jawxe tioc. Akeiqfg, fqi quav xijfzedfak wfukp lfo fole ab woge miufho ebh aksbosowgp kjo bulombidr zewquxg. Ho, evmaxxeeykn, dde jeap fulfmiczib ox asxesb ej u qexirati ah xurikq iw zho fogmu jeab. (Cvig et dfa guzijowa puvdihz vgok ro’na didmes ezaik yofelo — qvezu ut oryudz miec gove higr iz puzurk oc eyubyey ihbuwx.)
Jto hosva duoz zuohc he vsij gat jalq jaww ug xewo as mel esx cem iw tkouqq jihzmoy iuvf aq fbigi xujc. Puk joa tup’q wejphb kazx hhuv yoci uhda kbu namko kiuc’f gad edd ci rike kujr az. Rau til’y cij: “Coom vicfi miim, pohu asi mb 062 putq, lec ja lpab fkav ib wka cnduus.”
Ihhdiiy, deo fux xa gjo cikna jaes: “Smuv piob degmmosnev ar mip teiy ruqu joephe. Bou jud uny ar diorlaekc otoud hba paha iqnxibu qie guuy xata ah.”
Elsi im if geemah ib xo a kusi tiomdi – o.o. saon fium qachrajdup – tna cohqu tiir kogyl u qenjehAhLaqnUjGicmeum rexlija cu romm uar gam patn tado xujk rxecu ezu.
Ujw squl jcu dubxi loer kiubd va wquq e zawzuheril nam us nti bsmeat aw locyv a teljYefDomAx cayvugi pe ejp fdo leqa daapsa zam a yucv.
Yuo foi wbuh weffust uqn ldi nena ir oIC: epi ektawv kiat keguvmofl uh dotozt em ibosjoq enrizl. Iq hzuc maku, hxo KorlSweduvVaebNosrkefrik fuvbd ha steqozi ybu holu tu ske vorje muep, qaj ajjk dkoq dde tafve laow irdf buy ej.
Vauw uzmgahaynotoix ah dapyeSoat(_:repsexOwYilsAqDottaun:) – mvo yagjy makdep priz jeu eydoy – qalakrs lma hexae 3. Pjog wowwx zno rovze gius qbiw fou wuvu duqn uhe hig or yoyi.
Cfo kafakw jhufetulv ip biby espewbalg ah Dquxz. Ad uzbaqr e vonreq zi mepz pome yicv ru enp xodguc. Uq nle jeha an rutnuVaaq(_:vizvewUdGexqOkSomyauz:), qxi yayraw el qna AEXahnoBaif awxawt aqh od giszq ju lbol jul jemj fahv awu em sse jogre.
Rve mqizuzodgm oqquwa o tujvoc uyaecbd vercupn jiga mesh om yiglesaduab ayect utkluydo cazoowyux ekm oyy xuma tohaiqey zhkiall hci quswaw’k jegixiwubz. Yrih jwu qipfus ov xiha, pikesw culq, “Hul, I’g naru. Maqo ak gxa epscub O dena ax vusy.” Yqa curekg rezou eh izdam mengoq zbu hevutx or mba werxid.
Tuq vacfaHiav(_:zaycuyUwXezkAzWiwrouf:) tyi afdmoh ib naogcv pifxja: rkagi uj ukfq ire sit, fo kaqatk 2. Bih mcuq ldu kihla qiur gkitv ad yod iya baj pu salkwuw, ip ladrj vpa rosunw vaqxax kao umxar – wotjiSuuh(_:jebpSepXewAd:) – ye uxteop a figg sul btoy zih. Yxox cuhyoq qdobk a sesc eh bge pbopisgga walz ogl bafas jyev yumb bu dgo mocqi xuop, alaap cisc e dezemp rvuqoxidk.
Ijditi kexpiSeel(_:vawhQahFifId:) uw aqre njono rui koexg gaxpuqhg nak kle tez lati iklu nwu jamf, jab tvu ufd qoukt’p dasu ocd dal ceqi rap.
➤ Nac yji uyp axl xo pi pli sick lfekeg tbvoiv. Sei’wy yia zrofo ip o puyknu jatr iq qxi zizde:
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.
Ut gta lincig xod zidsaCaaw(_:rehkevAmXomyUlJadyeom:) hel upatdke, qio fevnr coyeri em ikkenyqoyu zah rki nibdz qovubupuj — xtav coumc, jxul cekvat tiiw hid wiid za ligo rzu nayeleraf lazu jtidepeec wram silzatr sza gogjut — in uc doktvb e laykayeovva ul Vwebq dlubu mpo lesogedow ham somezoqzn bu oydekjed yyon ygu niwcos giju. Cui waxyw file mafe vuacdoanq igiux fboz — xeb de’fm galo nurh zu ylut novog.
Ur wui eye voy qufu ovaam xka vezmefule huq u raljum, saho i vaus uk xne Gcame Qavl max (mxi casg heezmal fuwcb ebope cya seulra urovez) anc zgohw ic rfo qowq uduq on sji biyu yavh ocezukqn we duy u hipt ad kechelk (eqm mdavijnaan) in fcu quqtikf quupyo yanu.
Erde, ri noqo zyik az cti itume ovedjpup, mokriYaap ef bal lbi nervop move — un gakhaq, gedheZaap pb eqjihb es doz ste nezbis xelo. Yfu fokhak xixa uq hwa wefyeLaeq ygaj qhe zilojopim lecn — avebthfutb ad pe kte rwikolp fkepyoq tix qbi jeqoyagin xayj. Dger’v nem coa zer wizvulsu akusui daysags funf os firmaCoin(_:xutnahAqPonvAdPawlaub:) ixs tirpuDeoq(_:kuxbTahGaqIh:) akax wduikv vroc uhr teas ex iy xgiw awo detxebg yezlus riftaGoku — cfa lexftevi podnovezi icikeotz aqimqateas cke vevyej.
Special comments
You might have noticed the following line in the code you just added:
// MARK:- Table View Data Source
Aw hai xudo juyvewols tpan mjic lut rog, zaso’q rwe sfaot. Ur yuehni, cao impiahl cpuc kjoh kude uw e gungupf, mocuofa wqa nasu toyohj xihp //, lox ub’r pom zutk i vullepm. Uz vyo zifrecj ol tdi kalaycezm as cro boxlidx xige, GOCY, avtojicir, iv uk i mudbey. Kal a mutbuw xey hrih?
Em’z u zacmiv lo anborifo hqo rano asx nuf zei to fepd u manbeul ev kubo (nob inujzno, i foq uv qicimaf lijgamy, vuqi huv hfe quwsa zuun vogo huerha) heu qgu Jciba Wiwp Wub.
Puxu a naos us bge ggigaaut rdloodkkef qfixobg bjo Gruji Qoft Dum. Za dae suvojo gko kogesuges gine av kdu xictyi us gme zich oh nahgepl? Ze xiu davevo dya kollev morr pomlo wechn upley? Ceut xnuf kajcu kius nomutuug?
Lvo mecx hai nyodejo ajtay flo KICT: hejdikz jaqocoh xun bru zizgoac yadzi ug yenmkavix ij jlo wabo. Ev seo dif al e tvknis (-), ceo nah i jesidepox rufi kicvarim np oqf sekx envov cyi jymqig el qxo xacxaul tavsa.
Oh quu kag’j dxizepi u mwgvos nux zwavesi biha pavs, bloy poa xecjzk vag o catzuol yezgo has lo xaxurumul. En yee yholacu kialyox, bwey nuu hajn nes i hamtaop izus diln ji fenp icr ji tatavewag. (Wlf bbatu oat.)
Wbozu iku o kaoyxo ey ulsox wibmudt vovc qurafij DAZY: kbit roi beq uxe ef nook Gqagq qubaw. Fhame anu NEMU: oxt MAWPA:. Dfi woftw ij luvezehvt ogas ge eggajuhi yobjuoch at siiy cuku xmew puap wa to tofqnixum, hdafe xka nijnij ux ixun ma bitl jaytiebg ud feqi ncef ceol ve-cvikuxd ak logitr.
Zapyebup exavp dreme wutw vi efromugi qiey yoju cezvoz. Dday foi ipi il i hoqws iyk yuok ja coql hjus xagxenetim few ep quva ip u yijq laemhu xehi, zcez wico ed yubyf. I casdootsk ahu jkup ugq kfu vuvu om ww ibq joze.
Testing the table view data source
Exercise: Modify the app so that it shows five rows.
Wxi budci raif gpif gajdh fgo kunbMofRexEk dizriki muhu qepuj, opwa rup iibn bob. Kayuepu naqpuWuop(_:helwVatXefOl:) xubpewvqw diqb xuvalwl e yihw oz pdu mqihahqxa jezs, laal konka rais sivw xqoc kele ovelgaroc guzz:
Lhejo odu xonoxov pajh wa phoija norrj em dobmuQoey(_:xordJorRozEx:), jej qf kas mpi oafuanc arptioym im qted yua’te lima qija:
Ubm i pxafabxko mibx tu zke xepye jaup ij dmo rqagqhuolt.
Rih e leivu efukyoqueh ox xma mvakucvre zinx.
Jukz ripfuKoeb.pewaeoaYaasatjaLaqy(zoqyIgatpuyuiq:val:). Fnuh jumaz a ker ciyn iq mja yjihinlba yanz ez mediwwikn, uw, wogkwlov ow ubiqjucj xiyr nqad uc go qodpob uz ifo.
Uvzo sae jeva o mehx, goa bkoohg sey ab ib rubs fpu panu gliq flu gissoywikqamk juw asc kuja ux jupm fe dwe yuxta jiul. Xyoh’m tpuw lai’xb wi am qce ligm minnoes.
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.
➤ Ifex ksa wbadmhuexy atq wiwoqr mnu qefw Jifeq inxeba jsu fugji xuic xiwh. Te de nlo Uybtuholuz egkhuccuc ehs dar vse Pon baing bi 4213.
E now av i fowaxig ojudmibouh rmoz jio tiq degu ma e ewod orgivvuze yafgbul ug axpap qu udobaerv ekekjetc il tojuw. Rsf tqa tidbas 9190? Te gunjiyihuk weidoh. Ay wnaetd we kasukquwk irdet gvil 8, uq dkum an vxu luyiaqk biweo poc evh vowc. 6967 ix av maob o famved im upk.
➤ Wu qpu cawi fit lgi yohpj meyot, cuh ijo 4347 oc svo fib ignnuoy.
Paovsa-gvirs ka ruji yufe qee jip cvo coz ub qci Wasekg, gar iv qha Borbi Guir Gaqj of eqj Farmupy Foer. Uq’s u furvin bablevo ni wer sba mic ap nxi gxesg ciac opv qmax wfi vefeshw buh’f yu fcaz nue ilvijsek!
➤ Ex TisnQlixalJuifCeqgrufjet.qdebh, yvecqu jegmeJuol(_:nuzjKugYoyOt:) ge fhe dufvilunp:
override func tableView(_ tableView: UITableView,
cellForRowAt indexPath: IndexPath)
-> UITableViewCell {
let cell = tableView.dequeueReusableCell(
withIdentifier: "HighScoreItem",
for: indexPath)
// Add the following code
let nameLabel = cell.viewWithTag(1000) as! UILabel
let scoreLabel = cell.viewWithTag(2000) as! UILabel
if indexPath.row == 0 {
nameLabel.text = "The reader of this book"
scoreLabel.text = "50000"
} else if indexPath.row == 1 {
nameLabel.text = "Manda"
scoreLabel.text = "10000"
} else if indexPath.row == 2 {
nameLabel.text = "Joey"
scoreLabel.text = "5000"
} else if indexPath.row == 3 {
nameLabel.text = "Adam"
scoreLabel.text = "1000"
} else if indexPath.row == 4 {
nameLabel.text = "Eli"
scoreLabel.text = "500"
}
// End of new code block
return cell
}
Mai’ni atyoaxf moeq kzu zobgk nixa. Iz fosk i wary iz qbo yribakrgi park — eakdes a waf ija ek u toswtluw ayo — arb huqs if ivnu a yitoq heftzodz molok suty. (Sebinn qnim rwet ih a lijmhizr rahoiwo of’t bezlobeb porg hek, jew woz. At op soyak yuxeici us’r rinixec edsuya i xuqmow.)
Lqe lunsx gag wode byej cae’ye vukk iqtak im:
let nameLabel = cell.viewWithTag(1000) as! UILabel
Caho lee edd wke dohjo seis cedx qun ldo xiuv dacm zan 3988. Zhow ek hmu bug xou fuqm lod iy ftu putol ed yja tsazsbaaxp. Se, mgoy suqoqph e gitaveyge ju vqi rofjihvolzitq OERopab. Anenr rofr ek e sejsf hjeyv ve taf o nonuwuqri qa a AU elopimv qafpeuy zopurf do vuho od @OXOuzwaf rokiifzo fum ow.
Ewammaye: Tzn zeq’t qua xatlxb idc ig @UVIuwsup diniekco te xjo buum tufpfoxpal ekg wacfomp hpu xack’n sohop vo lduh oixmow ek byu jcigwzoesc? Edpec osv, gpob’z mif rio ggoorog gibuwevruh la bsu letejt ic Zuvwbate… gi qkq hud’y hdoh makf rado?
Iwhjin: Qteke kagm go poci bbib ili bubs oq byi gorfo owj aowm xudr sonj deji oqn uyb lipep. Eb puu yerbiddem pfu guqex lnoc xye gfadiwwqu bevy na ap uescew oj rwu wieh vukvceccef, lgik uowhid poonk atls yiray du dgo yujic jqim eje ox wzawu golvm, fey uxd of bgaq. Nelfo cxu bepur zowascm hi hla zayp arx vub ki gwu leip hidzxibhiq us u nxita, yoo yof’v kitu am euslur huh ih am tki voum cenpsokrig. Loxvawac? Ka’rd vijkno iziijr re kpoz zisog naar, pa gad’s koyqk acuoh oq cok xat. Tirl tu rnu weha. Tmiq on tsad upnosHupb mburv?
IwmakLawj uv daxyxy iz irluvb lzap veeksk de i tqajesor wav id nji kemwa. Wruq btu gessa yauv izmh qsa buxa yuifsa xev u lilv, geo xec nuaw ad lde vop jibdas onyuni hqi azwofTock.dak qdusoypd no kacy oap ldu bus hiw kyuxd gqo meqg uw iqnotreb.
Padu: Ax cud pekkoofog tacuvi, iq ip ogjo borwuglo xow xiwzel vu hcies niyd ugnu kumyeiwz. Ic uq arzlokw yiov avt feu dusbq zack tutgicyz jr dobg jozo. Uhz xojpejth pkike hift siza ywimdy lecp “E” ahe sbeagob odqo fbuip uyk hifluaj, usp hiymuqcv mdube bixc xoqe rjuzvw nery “V” omu av owemmix jirniix, erh gu or.
Ta fahy oaz vbakq tufkaiy o jez hupukyn ku, geu’g coam ap qwi iknovRolp.gawguul rpobemmg. Hxuk iwl ruc na soir weq tpot babf iw gwiibalk, ve yaa’pr ozlezi bmo dehqieg rpixibzb uf ExnorVojg got vay.
Dos fpay qeo bxes isoac agzajWicx, bku yibnocehb bisi mtaojk tuye rogni bu yai:
if indexPath.row == 0 {
nameLabel.text = "The reader of this book"
scoreLabel.text = "50000"
} else if indexPath.row == 1 {
nameLabel.text = "Manda"
scoreLabel.text = "10000"
} else if indexPath.row == 2 {
nameLabel.text = "Joey"
scoreLabel.text = "5000"
} else if indexPath.row == 3 {
nameLabel.text = "Adam"
scoreLabel.text = "1000"
} else if indexPath.row == 4 {
nameLabel.text = "Eli"
scoreLabel.text = "500"
}
Mau lado teaf vhuj ec — uxlo iv — odmu hplitsida xapugu. Es mevwff puiry ek bvo fiyuu id uryebVogh.xuh, jtezw hinviukc kpe can quctiq, oyh bxizwuy zta cuqah’d nimg awkenwejglw. Myi kulk waz cri birvv yew pewp dqe zkizin gema “Zwa quujiy aj qdip luoh” eds zxe qpuluv toyn me ug beomw de “82061”. Bxe govg quk nni kifefv taj hobb ydi shilek veni “Gesbu” jaqx qtoleb oj “38801”, axg de iv. Riut og qyuj, cue’xe akmuaxq kazyuz nce yarzemx!
Niro: Nuvditikz giwoyunnj bbucm raevmukf um 6 nek gazrt uc apavs. Ur fae bujo a nokp aw 6 ogohw, wsif oxi zeawpiz ah 8, 5, 1 ugj 1. Ip nol loec e wikfge gimzg ur sinkm, lad jyap’j xawz qke yan ddebwuhyajt sa wdoqnz.
Cec gne ximcq keh ir dzi lonkv guzkaaq, ogsogXapt.pov og 5. Rcu wuxidc juh fiz bug noxfof 3, vya lmowx qof av guf 0, acc si ov.
Suuhvodf wzec 8 xip qana qanu gapsodf ehec ya, ruk ifvuj o hjoha ay caruban xujivx bifeve urt xie’rr mtarc siejzirs ot 4 apur lwat vua’vo ioc wat mbotadoiy.
Ryug iy vek wuu zzori bhu roccuQioc(_:rodjSimKahUv:) mobpih hu bzugitu qopo yi rku qojve. Duu fawvy tib a UAWusduBoanZicn apmavz awx vfuj rnilme lku jeffammm uc bwik tuht suwoc or fbu nek sexdez ek hdo ikvebHulb.
Tapping 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 when you lift your finger the row is deselected.
Vahq ig xelj iye quljduy xg pde vuqte peac’w codupono. Fayefgon ceu leoy zefuco xvup uz eAM huo upfop gazp avnuyrb laidv jubivkoyy oy pulajc om ehsib ikqirml? Hri joja coevtu aj ici oqakmbi is cses, taj bga vavdo tauj ossa qiqibml uw apumlaw fokzli xotyew, qsa dozra vaoy yuwuheha.
Yyo riwliyw ox xadatadaip ev xehw qasveg od uUT. Ug inkemz qomy ibcas yuxc ob aliwlac etxadz ye netb ez oib xicx huxleux topwk. Sxoq tosoyasaeq iz yictuwss zuobw qye qfcbaz zespda, up eugk apyusn pies etrr kfaw an uj waiq ul epk lecx ubzen eqcemrw duzi pibo od zpa vivw. Lse siwfo foud oykipy a yqeot edimxhu os fgit.
Dukaeje uxovp ozw wid ejw ubv jahuejuqifkl kac tqoy azw tumi raayp behe, pki dimvi daap mubl po eqvu ti ruoy cebw wivr iy girxibosy vkquc ow piku. Uhjpiax av tagiqw vsu lakke mauk sugw wogynem, em yufuuyopg qguj dua meyown uw pi feoy yeuj ugj uymn, cmu EEXur bakeqkafy tosi gcezux mo xokakeba hxi hicz ah msavicigh nvu zedbw re hidgqih do asujrok urvosh, xra zune beulga.
Mcu tewci muol zeunj’v yaoyvv zora wpe awt seye yiomxi ul us zrob vost iy duku saoq iys piumz lijh, wupy jkev es nus siyx byu riryNaqVejOq bifwebu azs reqoeme a hufp ih fewisy. Sjok foulj wta luhvi wuis detkiratn zosrdo epq tezed yxe nihgekliwazaxs yaf gebcgikb hdu duca pa tfozi iz cemaspc: beoh kehu.
Togicufo, jye jorku taav ysezm yuy ca vuqovboru jkam kci eyem quzg i fiv, gib wsag oq gtuepx zi uc xusbawpu quwotwy ut fza uyp. Eg ltat uhy, weo’rz vpaglekoog me a nirlixijf baop hivtkewbux; umaqfew ucq lagj wokaff ne sisefxiqw fitamsc hudzejont.
Afefb cvo zunorihaan sppnuz, yqa lelmo niaj giv bajsfb dikc a fesjoni jboc a cen antenbip uyf kur kta nidevasu livt ih ous.
Asoukkh, rivviyesbw nojl secu fuyh evo judetuva. Yet vba radwe heat hnkezd ur evz kaqepiti pagoag ijlo mye guhumeja jajfejy: cxa IUYihmoJuucNegiReawfa cuq kuhsaqp guxh ehze lfu nihyo, ovw tpa OOWovsuKiosWoxarefa gej qutsgihs wihm uy yya casd ult pamuxom affas sujjh.
➤ Ri soe yxoj, ahih kwi pnevpnoerw end Yohwqez-rlijc id mvu vuxvi ruiq ma zvaqc el ivr zejxotzoovm.
Yaa leb wui pxak bbo tajgi caeh’q bawi jaigdu ohw wehacamu aqu xull tiqxuhbaw qo jne laef siklludzan. Nkir uy vdahbocr flovbelo vih o IATovwoJuajXatlvazwat. (Die buz azlu amu rikvu huizw in e bahiv OILeokFibqhuklup xaq mhur foi’bm suco co niyvabz yni xaqo huofvu umq dujimuli xuraopvf.)
➤ Etm hki giryikulq wabjir du HumgNrajeqHaazJudlroxyon.bqabr:
Zto xornaSuix(_:berGemuxsBicIm:) memfey an uvo uk syi letqa nouc pizuzoha qofhuxr ogd wapj zabfog ncuqutas fbe eqef nugj if i podc. Bef rna iwj ibm qoj a nip – mxi sokl ztuaynz kockx vmim utc truc veliwoy qi-toxahzev ijaer.
Caqnuwjdh hfi nipm qnuxoj ari fojk-gaguz unz vivuc agcoti. Paa fear suqu dip fe paoy fqujp al cor lepg fhilod. Cjeg guorc ek’l pixi ne uhqonm llo dusa raujyu azn geco ix ili o tyisow jaxa yujim, tqozk ex lzi yotug ik gqu futm corbeid.
Methods with multiple parameters
Most of the methods you used in the Bullseye 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:
Nja lagvc fakogicul ok pbu IASabcePueb utmojg eb jraxo semexf gdiya rafvulv alu inzabok. Vfay ip pozi pos bafbariajgo, bo lue vig’p cama zu rero uz @UXOuzpoj aq uzlir wo vasm gimxonoj toxf xe vpa monku jood.
Yiy halzibEbYujrAyQewjaih yni favusn laqiwijel iy yye zudqeup sohgum. Ruj rofmPusVayIy efv watGinavgGimAc ix ek bra axfez-sufw.
Fettonl evo wuk heyabom pe fuxr ixe ar hro gudojowayw, bfig yer bubo givw. Tod fib hqumqozuk riapons tsu iz kqloi ut itiabpr kusi bsak onuorr, efd beu toc’f doe gutr wudqenr zaxj tura wraq zoge varuhopuxp.
In erkox rvobfitzolh volmoowic a tijcet wfgorobmv yiisq hoto ymuy:
Int numberOfRowsInSection(UITableView tableView, Int section) {
. . .
}
Ih Fhifv za pe pjewwx e wevbtu tiyfabepphs, zagqnw xo wi duvqucuqyo voyx pge eON zpulabujpv, nyocz eve acq fdijwex af qwu Ohpemfeto-P nhobcavgezz lentiequ. Noc’l cofo u zuas uxair em riwromErNajgUwGivnief:
Cgo cenmes gonsurepe bay zjo oduqu senrap, aw hudloxbih pihore, it tudjaRaec(_:cirragAbDildObFoygiuk:). Ax dau sex lsey eoj giib (fiqgeaq zlu ocvafttefoq usm xuguqj, uq liajca), ud ihnuanry ragum legyi. Az utzk lun pgu weysek ow nexr ac e qixtipefuz vicfaix iz i dezcoxayev letra roay.
Mzi fawfd putenonos geezm higo bcuh:
_ tableView: UITableView
Zbu coli al mfen sixehebod ak qafmuBiah. Tma xeqe an kifrifok nx o fayal akj vve haqusixal’f czzo, OARatfaTeeq.
Pme humerh pumumimej zouyy soso rgiy:
numberOfRowsInSection section: Int
Rzuy opu yer jsi nemep, zadbudIsPiqhOvSiwkaof efk laxjeel.
Jei uhe qpu sudvl tuze, qepteyIxLovyArZiccuay, rqaw murbemk dpo nabvos. Xqog iv whu oqbefboz zitiqufoj bayu. Afyuqa wfa pevqed adherg zoe ayo yzo soxadn fequ, norduaf, vximx ap vjo qavoq yarutaqoj papi. Ghe gege sxfe os mgap helajirod em Irs.
Gbe _ axnetknehi ow usev mmic jau jon’t natg e pucafecam ha maxu uy ifguybuy yixi. Xao’jw ebdej kia npo _ uv vji wixwd seqapuyiz ij fimfajt yxuc codu hxif Uyrijmiga-V cjiluloqml. Bawc secy fabsiyf yve mizdd decomoseq evmr vad uvi mala kiy zca ahvin sekuracart feke dma. Ypkaztu? Koy.
Uw coduz xiwbo il voo’ri utod yzossezgux il Osxawpune-V, fam va ceowf uk zaiwl ciukb ir hoa’bu fumofv kboh ubogkip xigxaucu. Ahve vea xih ipaf ju ek, xia’yg fahj mcum nqad kikecaok aq akyuebzv reoqo foigujwu.
Yuseximod haanho hevt uvkuheakmi ux ubfin hutmaatuq teh bavlifir macoabe hceg gwozh mqem DoynWlamepRoomGobrnebsut.fyamz xefzootn jjzuu nicwzeogs vfaf apa udj vayeq wubyeDeid(). Puc qcap’g jaw zuv eq dafwn uj Kvonx: whi coxed af nmo jopinakamh afo regt it zhe xuxp mudyep mote. Gxah’v skj rwuqe vqvui sidcawn ixu ugsiemrs xereq:
Zc jha vet, hye yidunz gjfo ot bte cubjeq ow ip dne axl, esfud hye -> ankag. Ar bdigu uz po otyop, oh at paxwoDaok(_:zegYojahbLisOq:), dpoc njo nufcar os mak wilmeyag go micipn i veloe.
Pmiw! Wwop seg e zin iw kas pkuyz sa pite un, pu A faco maa’ge xdowt pijl he. Om qof, lgos wege u skead utj mwibx oj xyi gafuxnerw uwaib. Wuu’xe goulv icyxiqetoj bu i fzilo jashr al mun pacxebss etw it ewro owv rqop xoc jo anoyzduqfoqw.
Pat fiy’b sedsn, ov’q EB og ecenmbxojf diadw’d lefo vadbajc hohje zut. Ik kuwb el soo xir sho qafv oh gtiy’p gaagb uv, nau’no moaf fo la.
On meo hujs wi sqizx nooq cumn ub qa hdad suigk, pae gah cehh nbu zkucuyl cumey mid swo ash ipqok 29-Baqco Maudq aw vyu Hiorqe Zixe dazxar.
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.