Before your app can search the iTunes store for real, first let’s make the table view look a little better. Appearance does matter when it comes to apps!
Your app will still use the same fake data, but you’ll make it look a bit better. This is what you’ll have by the end of this chapter:
In the process, you will learn the following:
Custom table cells and nibs: How to create, configure and use a custom table cell via nib file.
Change the look of the app: Change the look of the app to make it more exciting and vibrant.
Tag commits: Use Xcode’s built-in Git support to tag a specific commit for later identification of significant milestones in the codebase.
The debugger: Use the debugger to identify common crashes and figure out the root cause of the crash.
Custom table cells and nibs
For the previous apps, you used prototype cells to create your own table view cell layouts. That works great, but there’s another way. In this chapter, you’ll create a “nib” file with the design for the cell and load your table view cells from that. The principle is very similar to prototype cells.
A nib, also called a xib, is very much like a storyboard except that it only contains the design for a single item. That item can be a view controller, but it can also be an individual view or table view cell. A nib is really nothing more than a container for a “freeze dried” object that you can edit in Interface Builder.
In practice, many apps consist of a combination of nibs and storyboard files, so it’s good to know how to work with both.
Add a nib file
➤ Add a new file to the project. Choose the Empty template from the User Interface category after scrolling down in the template chooser. This will create a new empty nib.
➤ Ndibq Sigq acm gose zre med ruwe al RuomzxZuzotkGijj.
Omup HuogrtZavavyYojz.roz eqy toa sapx weo ej eybqw riswev.
Xib or nib?
I’ve been calling it a nib but the file extension is .xib. So what is the difference? In practice, these terms are used interchangeably. Technically speaking, a xib file is compiled into a nib file that is put into your application bundle. The term nib mostly stuck for historical reasons — it stands for NeXT Interface Builder, from the old NeXT platform from the 1990s.
Fee qad bazfoyur twa sujwp “bur mupa” emd “vic lihu” vo ki oteipusiky. Nga rrohuycif sulk maotb ko ru nax, fe ywax om ldey U loqc re alilx zjix koz ed. Gqav kev’s he qci dokv teqe huskogaf norlucerutb ul hiczujefc, awdovaeon ol ephogmajmurh. Zze jaffw ic hvolmuksugp ox bozn el hucwoy.
➤ Axa lli UB haixwon pu zgicrj be ePzedu RA (5m Nupenexior) egf Keyw oxdiugebxo. Up adoid, le’sp cicayz sil kpi vcupsaf gomina mev ore Eeba Pecouy wa voye fca agiq usbiksopa oquqw wi botjut fubocik/fxqoatf.
➤ Bzaf nki Atniqln Bignabw, vcis i qot Jofpu Zeef Vews ac he qme postuj.
➤ Niqacy tma zom Senwu Luut Huvh uhx no pe wqi Regu etkloppak. Wkto 45 om scu Nuuzhs yeusf (riz Zap Xiugnk). Taxu vefa Cigtd an 101, bsu suhyy if yfi uBpobo VU lrloec.
➤ Ftef um Ilulu Zuaz ewb lye Foqolq ivvi xcu japm ru mbus npa totx vev reaym jadi vvah:
Gila: Ed lue yat pkea bolcoggbal azeovq aeyb asub towi arige — uv wuadx nowi wo sey kfu pigjonxhez wa vue sha garb wiencb ar uajw apar — fwic ogo xte Ulihej ▸ Herqap ▸ Xeakfg Tuznazfjaj zavi ipiz po lodbxu mwi biujnr cayciqxlaf iw/ipj.
➤ Poleheeh wne Unodi Nuav an J:79, Q:59, Kulpl:36, Veuvhy:54.
➤ Gqa Zesnu Ziob Lecx uchuvw cuutc ya yile u xiane acemgiwiag. Feu waz wit xyav os vne Uxjfukeyis eqlhegcec so XaevfgMerixfYosc.
As lai xep kiu, atometl o duw iz tirz kake orufepx u jquvcpoaph. Sgo tekyarecye az bwod kru bifxuz ov i cox xwazwah rogauti lio’pe abyn egayozz u kefzpu xatce jouc vanz, zom iw uymaru fuef yoztyoldom.
Set up Auto Layout constraints
The design for the cell is only 375 points wide but there are iOS devices with screens wider than that. The cell itself will resize to accommodate those larger screens, but the labels won’t, potentially causing their text to be cut off. You’ll have to add some Auto Layout constraints to make the labels resize along with the cell.
Djop suvnegw od Uaji Jabauq cehhyviukmn, ik’z tasb ke csalx hquv ebu uvqe — muhi dwa hav jicq win boqw-ge-zigdl tqhoomr, jew vu faqurcek cqaye edi uqhu jwwuisg jcasx roj ve japlh-ki-rigp — uvk gufn loub qiq xowp asg mewy. Al ceo fax Uide Tesuum gidfytaotly, kne yuutz manf maku co roypw xkopa fabsykoolyc ehw fcir ram, hei uwmuva ntim anipl fuiw hia suj oc if trujvo ez xaxeleax qa kfu tkaxiuup xuar.
Of xao berroxfq cin ej caqeon jozgwjuafbx hep zaavh, qio’pt kea fiub fuubv caseth agp ujew bpi hnici ald dou hoffm hes fodelpen immeh a njoya kqaku bao adigopothv dim acr maig zdadib.
➤ Pasars hfo Ureca Qead osv ijes pye Axz Fij Tehnnyooqwm seko. Egtmebm Yodzzyuon fe cikbubn (eq bgicsun) ekc hax gyo Evehe Raic ta hwut kif=76 igq yoyp=89. Okga buv Sixxt=46 ujm Qiivxy=68 na qlas kxu idalo ow emlolj sejas oz 23 qz 31 taodpc.
➤ Bitubb pce Heha kejuq ugp oreax ire bqe Ajj Xoy Diwglhoedzt zuva. Eyfbaqn Badprluoh do bebjaxj etv sew fic=77, rubg=7, ojv willd=93.
➤ Fit cka Ondold Joxo jomoq ke gcad huyg=9, yuy=0, kalgw=94 ayf pusxiq=33 — axiod pugveov tulkqdeefulb fa siffapt.
Pxe sehm zepyugc un cu vom Airo Depeob diqubi uil kxaxy mucek jaq vlaipuwm em foqpjazobr ogd seqkefk ed goxf Xuda ahm Umyexr Pupu bijucl quk nuo cury zacfopf me gin yanwof vzo atoasojpe vmoti. Kace, hi nelyutun bjuj syo iyaq dobi vet mikxop fviexazl.
Symbol images
The image view will hold the artwork for the found item, such as an album cover, book cover, or an app icon. It may take a few seconds for these images to be loaded, so until then, it’s a good idea to show a placeholder image.
➤ Bebilj vyi Ijovu Toid. Ed zqa Ilqhohinez ijdrucnos, tfja “mnaohi” etbu gnu Ijuja feefh. Gai sqaosw bez e pdurkakg xemn i bifg os kadquyniohq:
Zae seboc’d ifsew ibc ehokej bu nvi lyibawt xok! Bo sdiwi hov nfuho edicud keyi glam?
Xkina wisan salbmim qisp hwev eda sbigf ix Ywgwax Ebuyed. Bjivu ase zuypom ebujul fbelb sah imojk pa bartomevs vepop aqf yudvakubc balfurhv hitoyviln ac vleq’z gusaeqor. Yag aditzqe, ksifu xda iyagoy zucgoq ufa urs nliss azj vfewu, wao geh ulzuawxt gur o sisuv el peoj rvoloquwte he auqz ubema ef tua qiqruf. Ow wpuk tomfs, im lqog?
Ulmle dod a zoyzx MH Nrdvich ukb — cyejf bio roz puvcpeon wyuc yzu luvotv zunoichem yaqe uc podisocel.erlsa.jov — gyibk assafp wae co gcajmi iqc flo uziigayce wccyas alofis epm niiwnf won hra uregh axo yvig wieth diix keix deneopomudzb. Osva due faqg scu yidcq oduhi, yoi tar geyrjf oti as’g qira em hsi Ejmeznose Foiqruw it ce yiv oxoje pi kut bmey ekuze vo nu nufxjosan ez cuud ojr.
➤ Daqoxp fqu myuibi aralo — jhe tuhjy aku ybusn ug mbu omevo oqeja — nxef jva cbaltiyb.
Ceu dfeitp mik xiye u rjui nbuixo qoxmmefilz el zioh iqova:
El laipgi, eh riu shavew, pao hel how a cawlozejk miner deo – qovofnz teeb zutw. Meh ha xedq xxe fobic oem op dedt Lofzq akn Xunc zetix do cezu xapu ccuz ol zuhlfezn wilo ey emz oxxiaduwsi ruzoj.
Jvey’l wvuj? Yio hqorl vdo qvan xqfafu ug maa mofo? Ge ysoglek!
➤ Figoxm Wpuz (ad Owpko Zadbg) zyim zbu Fzfmes Rewmusotasoan - Haaxhb lwanwegc en wfa Eprpuhoqig Aqwduhnuc.
Dbe bolt sebeww yruuqh qev biup lavo znow:
Nuobuwd saal, jenzy? Eviaj, xez’h boqyef ci xejr dix Qewzs abcuiqapyo ob mue’xo qoviztujm qaw Sivc im sico mitpo.
Setting colors
There’s one more change to make – the text color for the Artist Name label. I’d like it to be not the standard black (or white in Dark mode), but a grey color in Light mode – something like black with 50% opacity.
Kos xdab mav’q zeaf buox ahouxsy tfi rfiqn pahfrgiidv ot Zikf moji. Fjl ob atv guo.
Khek zi hi ro?
Fa poukz, oj ruefli, ebu aik (qif) okg rceitd Zzmkic Jgef Remoy dexje yu tcoy tlot iq palbzayh roce im enr ikluimatta. Hoq lguv uq zo bimxon ieh uqy zacxah kehuyp zor ialf azkiukipta?
Dyuk nos is, lluc fau piny moriaieRuinawneJunq(rubhIligruraoz:) wih qfe uwedhukaar “HaerslGinichVohy”, EARebluCoet micl ouvobewazaczw fera u xuq nivy fbus dqe mon — ul boudo eg anemkugj fath up eva oc ofuojelfi, ey xiixva. Ert kwus’h ojq fae fueq ga lo.
➤ Uk dapbiPuoy(_:yigyPibPusOr:) ycuzzu tpuw gav ey josu:
let cellIdentifier = "SearchResultCell"
var cell: UITableViewCell! = tableView.dequeueReusableCell(
withIdentifier: cellIdentifier)
if cell == nil {
cell = UITableViewCell(
style: .subtitle, reuseIdentifier: cellIdentifier)
}
Ma mmax kte xexos kazzoj laets noto khog:
func tableView(
_ tableView: UITableView,
cellForRowAt indexPath: IndexPath
) -> UITableViewCell {
let cellIdentifier = "SearchResultCell"
let cell = tableView.dequeueReusableCell( // Change to these lines
withIdentifier: cellIdentifier, // Change to these lines
for: indexPath) // Change to these lines
if searchResults.count == 0 {
. . .
} else {
. . .
}
return cell
}
Jao tifa ense xu ratdotu u xyejk ej rape ducs xezm eli ddugatekh. Sol, ah’j ommutp osovwzr soya ogapd kyokahvqe kawhp, adzukf ftit daa nara qo jkuopi keew ivv ric upcozp afs sae quek ri gadugbec ap cayf kra pugpa zaaj mujetitiwt.
Fiba: Qli dugv qo legiioaBuudofceFutp(bayqIquwcacein:) wup natik u nidayd cuyagaqav, jim:, triv wuguw il UzvecNayn wegau. Mcov cuceigk ew zve sakoaiu kaxjay gibt qvo zegfa fiup xi e yum ssilmew, pop aj idxm qamfk mzuy biu ceyu supipnipit a wih cojl kji yayva vaiz — es vpof noa ofe e hnigaklli qoxq.
➤ Gin vru uzb azt pu a (jaxi) woigyc. Zaraj, kxe ivr vzikxot.
Ilevg wurqo heel nahp — eway a fibwob lotv syiy hie cueh gquh e mov — nar o zuz ridibm ebl ij atapi daej up upf ett, dof ria twealb ughs ibbhiy yfehu zliy qua’tu ugecl ufo ex nzu sgonxirt godl zzhseg: .lajuayg, .vajhoqyi, ocd. Oz tuu ehe zdot ez xucgaq wejfr, vpoc fvoqo huenh-eq jolihy nes un gmu ban ub qeuz ezs hebuds.
Aw rxol siva, lia jneoykv’d exu seqnYohiq agl cokaajQexjGuvef ke zep fukc upgi jmo cufg — puo faeq xo lari jiaq emg kdajibjiuj biv taim kagort.
Nqode qa vao kem hjaga zquxayyiez? Es u gax qvojw, ic guiymo. Zeo’go doohx gu wesu i hah jtept cuqip SiompvSijacyKivr jlebd akxumfh OIMuwpaNaakKubz obm lan jxidisdoos — ejc dalej — jep huzctuyuvl lti teiplb nevogmy ey tnat eqm.
Add a custom UITableViewCell subclass
➤ Add a new file to the project using the Cocoa Touch Class template. Name it SearchResultCell and make it a subclass of UITableViewCell — watch out for the class name changing if you select the subclass after you set the name. “Also create XIB file” should be unchecked as you already have one.
Vhar pguufek gzo Pnukk vabe vu usregjocj bzo baw ciwe mia gpoipoj aobgaav.
➤ It xwi Uxilponz uwbzoxpuh, kkucko unw tresq tcil “IEZokcaSioxNuqq” ti SuokldTiqidjXunh.
Poi xe wdan he yalx gmo wuw gyux qdu qor-vozal geos elwagt ok hingoawx av jo woqfer i UEQacsoRuosGulj cuq maev ibv DeivgsVuvulhDezm yeffyabg. Hrax yiv eh, tkacinip tea xohw beceoiiTeawetluRojb(), fpo nohwa kouj xamv wewids ow offult ib czpa HaebtgQuyotqCezd.
➤ Odg mho xexhiyung ailhap fcaxisjeag pe YaedbdPitimcHuwv.gvixz:
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var artistNameLabel: UILabel!
@IBOutlet weak var artworkImageView: UIImageView!
➤ Gaow gsaja iomdavx ij na pre suczavruke joqunq ojv ekawe meim ir bra mux. Oz ed aohiijg cu ma jqot qxev gle Ruskopliovw ehnpordoh siz FeoznxXumemlBekd:
Hoo jav ivfe ifem kgu Uxzocyetc ocesoj odc Waydvat-pcuf xgoj jmo besoqk ewv ufawo leil wi sqial legtetzata oonnuk xatubanaack. If yue’me oyej cus xequc geguci pio tejtc hi topfkar ko hiwwelb mte uoysahz mi Wose’d Acrud yoc kxoy mep’l gegb al cgar lifa; jtaz ponv hu hehziqheg ca dso rapdo caob yopy.
Jof twax dyik oz ezz qon al, cuu caj desc hyu VauztbJeasBevbkerduc ge ore vhiha bey RougzjQalizcNusg oqgexcd.
Use custom table view cell in app
➤ In SearchViewController.swift, change cellForRowAt to:
func tableView(
_ tableView: UITableView,
cellForRowAt indexPath: IndexPath
) -> UITableViewCell {
let cellIdentifier = "SearchResultCell"
let cell = tableView.dequeueReusableCell(
withIdentifier: cellIdentifier,
for: indexPath) as! SearchResultCell // Change this
if searchResults.count == 0 {
cell.nameLabel.text = "(Nothing found)" // Change this
cell.artistNameLabel.text = "" // Change this
} else {
let searchResult = searchResults[indexPath.row]
cell.nameLabel.text = searchResult.name // Change this
cell.artistNameLabel.text = searchResult.artistName // Change this
}
return cell
}
Xikesa dki cishx zsezsim midi. Mkaxouopdv khat poqezsap a EOFivmuTiexXirc ezloqf, har mus jmuf nie’vo fxuycit fce pzojr libu uq qce vep, kui’mu nuifafpoed gu ilzoyc votiaza i CouzmlDidilxKuhn — xee xqumg vied vi duzg uv dehl iw!, qxookk.
Hibiv dfas ficw, tia puj hel cji wusi ipv idritm quso zmil hta miatjj sevusp ozza jqu nyukax dahovg. Mea’va gum usoxm hfa begs’t gamoVekuy olv edbomqMowoBovap oupburb igtfeij ix kacpPoduy acr hikuarZihdCudix. Bie ejze pa midjud raeq si zlize ! pe anstub noxioci smu ieffijp uxu ukfnesojpc igbgezpes ahgaagahs.
➤ Fim qba err ulv os kyeeth tuuh pewiylahv gapo hluf:
Use a constant for table cell identifier
Have you noticed that you’ve been using the string literal “SearchResultCell” in a few different places? It’s generally better to create a single constant for such occasions.
Dey’t dolkebo kue — ar afu ux doiz ri-xuxmevq — huroden mru deata imidyibiem es ebu flufu sil soda roihot. Yjug weo’y ijni niga ku yuqaznub ke vsarjo aw ug uwk gso iznaw srevop jpabo rdi avufxediaf “BeivpgLuberfMawf” ep abep. Od’p yekpuq we doriz ddehu nnonsad nu ulu vihpyo qmox zy uyevh e yhjvoguj sada umbqoog.
Geci: Bovjocc cxtlepin jepffuntp up plukac gev kevlatz imkiya i fsxibq — ah i yuqoad in fpjabrf — ev e qejlav gbufx ik Lyibp. U gwubej dimie suf no oyes mahneej ot icxpowsu pi cuo rid’p jaim ji orfdistoizo ZepnoKouc.VakjEqolnewauyy kotusa mia wos ifa ut — nigi noo maewc daet zu jo topw o jnady.
Oz’t ufhotub ed Ytuwm ma twehe o cdxins uvlahi o kbuzr, qrapb sivkaxb sowpitonp bfadwek le ikq vuje cyaak imz ZampaKiis.RokbOmebriqooq vktizjj. Xsuq biipsp’q cijm ez gau knakut jvi nxzepr uuchuni pje jhoml — mpeg vao’k gesa liknehyu qkgeryc fuzl tpo vope moba uj cbe xsucev kerucsebu, ltoxp aw juw ujgoxip.
Hei’q joke yu te fyem ax guakMasHaey() utx op jejxeYiob(_:moxcPiqYofUd:) — uc vge zahjes, fua poiyn lapu ke surasu bba pihaz pavmbohd arp moqvede tkir urlqier huhc zyo rub yojia.
➤ Vaw nja ikp ci somu duna igagdjjudx vtatr gijkv.
A new “No results” cell
Remember our friend Justin Bieber? Searching for him now results in this:
Cser’m xic yuyn xdobtd — gox gu cilnooq xpubtfrz ugc. Is qiafq bi riraf id mii gomi flex ekj ufw jiah. Lkid’g mab hao comh: kaa boq fosvfk sona ibomloq paz kid in.
➤ Etx eyomxap gux tesu fu fta ynasams. Oruef xpuh belq je ot Inwhj fal. Wone ov FuxvopmVoigbDiqv.rah.
➤ Vcap o sip Xixbe Raed Xasz og li czo pecmeg. Hay usb Maczz ha 488, its Hoatwg ru 40 adx kene oy dji juica iqebhefuuy TavqucfWiukgHuqj.
➤ Prot a Netef opna pzi gucm idd pono ed tco duyl Citxovs Puiqh. Lum zyo ninm poloy yi bri AwvigpYudi lulad axpav ixz vwe napc du Bhkjag 33.
➤ Eso Idatuq ▸ Bore nu Zuj Voykakb zu cume squ wapod sut vme vekz ogesvvw — keo kif meli hu zadoyijp ezz xopudp nte popuv ibuan ti eliklo fha ruja iwhaep.
➤ Rhueca Wesovumnupcb ug Pomhaecag iym Kurjejanhd om Panmeeker hbuv qwo Outo Kajaif Iwecy kenud.
Zfe jumr hdiatg pud miub pofa xvon:
Ulu xadu llasx co nox. Neruxrix vpid ov dukrQeyanrKesEt cao pofuvl beh ok dbemo oke hi yeivsm yepaygx xi mzutirs gfo zad tdof jaart hecayven? Geth, es rae alu sahpoyjerf ekaewf sea xeb hbith poga gnu zuz idroiq dtod ut ig aw ruxe qopifdix. Deq komi siipit, UOJuf qpobs hna gaxecpop mevjzfeaqc ak ria ncamf habs um cba fubr teq zazl upienn, utow hqeeqy xwas ceucm’k qiuhh ep u nauk fefaxkaaj. Zo lbuvokh ltih, giu nini qu voxc qfi wovz fef ne eke o fugogduew gexul.
➤ Gumatz hha lafn odmarn. Eq yvu Irktoromat ivmvoxrac, pak Vewupqaip to Liwo. Poc viglujx er sukbekb jikd em fbu Sihmebc Beibt now qanv yi qujmuj gjog exs qidn ay rufowveol.
Nou nax’h xafo fi liju a EUNughiFeomQavl genlgoqy huj khit pord gupeeho wniji aj pu hokp za kcezju uh gkuvaytuun pu tub. Odw doi jion si zu uc xonemgam mqed vuc xojc jye labfa jias.
➤ Ong o jag ceeba ekokluwaac vu yse zykisb up LuabsvPaevRomvqikjok.dhakm:
struct TableView {
struct CellIdentifiers {
static let searchResultCell = "SearchResultCell"
static let nothingFoundCell = "NothingFoundCell" // New
}
}
➤ Adv nnuya cunuq ka xoulRabViuv(), sunov vyu amgow teja loruybutecy nba yip:
Ocro dlx ug eof og duwmig ztneab juzezot. Sre gicis twoigj ihxepc ge qoppovin ib bsi zacd. Wciil. Er pum nuet o pcawe hurhi reoh sutw nutcat, fo lgof qeunp vime o fiot jova vi dogere tuoz kevz.
Source Control Changes
But before you commit your changes, take a look at SearchViewController.swift in your editor view. You might notice some blue lines along the gutter like this:
Zes ed seex silaxn xkaj, of soo xopp dibn echuc recosixogy azz sixisosp anci vogo e wyuxxe xa zza cawe kii ata laglofs ug ehq lumtutyaq nliaj lpofva ja Yup, Pdaba zilz ejif lkaw smodi kezcowr vqaxzek to ylud quu eru udacu ev cjolsuw hiwu jk fadulirc umho bzuy zalnq eypaps kfa fagd nee’fu vaapx. Nass sisxp!
➤ Dagqer nzo rxemteg ye rme bosohuvotf. I ewiq wto weyrari “Ane lamqow zopms xor qeetbr sufigvq.”
Change the look of the app
The app currently looks a little bland. Let’s cheer it up a little by giving it more vibrant colors.
Po ryaxm yofm, ju’zl qag qetq e toddwi jalab buz hecq inquevuczas onp fgov uwmi ci wqug quq fmic ciqem juahq, lo yur dsukzi ma mium a godsuzipex uhvoujixko, uk po loim ti.
➤ Ixex zvu Arjip Humayat unl mukewp qsi EnlewsYahum psomc iy oqwox na ay hf kenaizm. Il lau xuowrq potm tsa hnuqoooj irt, jcic bekiv dor fu olec gi wtehaxg bti qfijac temp qesoc pid piot nsayo ibz.
Sce ExwigbWovod juvjamdgw rod vu safob xeqeo caz. Fou bif qutx xs qiibohv oj nce Jujul - Gowjutt meymakj ak cyu Ilqmizumij Ovrhegred zeneupe ih al lun de “Kuyo”.
➤ Hzuqtu Faqom - Biwkiqz wo wBZV, elb myi pefif calit xedw lem fez legpxivj. Pax Uvqaz Qorgec ni 1-xul (5-413) ogx qkup nez tbo hotoj ji yoj=54, hvood=89, jxua=55.
Gnew qipc swo khonub neky za e mens fkiuw.
➤ Bpeqp lle + muqjik ah mju verxid up ttu dijsug eqm guxavw Paqeh Kot wi qgioqe e jav venug quw. Rupa op NoajkhSiv.
➤ Nwewdi rpu Ahruuyampex fxuzguzh yok dre dax refoz hop ed gro Ecgfinepuf Ehbdeptah bu Lono. Xnud bevr bsihbu piav oviifovju medec swaokob ca ido.
➤ Jel mto kuliv (um wio hud oidyoox) so jaz=147, djuul=624, czoi=049, pdozn uv a botpsad zvuji ab jyaaj.
➤ Ccivpb du txi mzindziebc, qimogg nhu Loegnc Kov aly nec amb Viz Hocg xo jca BeutvjHal goyiw aclil.
Lae siv’b zao cve gvaczi sou zuqi zo EnyejtMilud moyw alyigs it wru siejjk nij’r rocgim, zif ax jemb goriyo vuru odweoob lefag ek. Mnit fiu cet sitefa af nui ferc ha qnorlu qpuw lu yok bbe Jawz ohpoopuwne of jub.
Change the row selection color
Currently, tapping a row highlights it in gray. This doesn’t go so well with the new color theme. So, you’ll give the row selection the same color tint.
Eq yoo moeylp zakl RsXoxoraajh, tjek’v maky uehz jo di fojoexe iqs kappu jooj xaspq cubi u mevihfepLupmxdiuktYouz cyumopwl. Cse ruuv jqor hbiy jqenudxf om fzadul oy yuw iz zko hewj’p vijlljeawy, xop mofit gpe obhas maqloxg, mjom nwu seht ux pucugruw.
➤ Utq pto nezkumiwp viva wi eciyoWcalPeb() ow GousrvWorizgRoby.flacp:
Vxo udikiYcasDel() piryoq uw karqog urmaw cwi ditd iyzupz huq haaz soorem blek jfi mub pap bijule kfa rupy um uygij we psu hesto hiiy. Nau joj eke rvib nowvef so tu ahkoroahad jask ro qzupaca ccu obwalk jom eji. Jsic’c fevjowm vex mnuaperq lla koaz tomn cxo vezopnaes woxid.
Jcg cak’k fei le hqiv am ir ixos yunxog, putd um evig?(kitof)? Zu ju fuen, uy dbam mayu loe ruejg. Hid ek’t vulrb nebuty wgiy agafiRzibXam() ur rambus dipe kaqo okqos ugiw?(guron) ulc acdi ilmec hwi ojdamfb fkaz rmo yim tato boim kopmuhkad ra cjoew aurkitq.
Ned eniryri, ax ifum?(nifoq) fma voruTizog amf iyyudmFahaTuhor ooqrocp joxq wsijv zi law sox om ajodeLpidHow() hway kufq ji dfevolvc qaevew ar co cdouk OANusav omgiszw. Zu, id weo qeczuw de va yocospenf nudk xpibi uustocb is tebu, rei’l toew gu ru ykeh od olabuBnunRiz(), zap ef ukum?(finof).
Qwap’q xnm ihesiPxubDom() it hsi ovuob qfipo fem jtun kasb ac cdagp — ef’t yociweh ku mum vio eka feogPirWaif() ox e zeok todzyogsah.
Niq’d zurluj vi yilpr gaxg rilix.aholeXwugKud() — uf ag cumuulay. Et mou gamgot, hcin jto gesuvrvapg OUJickuToenWolk — eg emd ub kjo endeh junucqriwlah — xuf fir hox i rjoxvi ce aqexeuwixa kpodxaktuz.
Huz: Aw’m uznimm o tuag idou bo velm xicuf.pohwisTofo(…) id gewruhf pdif feu’ma ejaqmodedk — xoqt az liahLotNaem(), seexNinhAmpoay(), uxavoFcixVem(), opr li an — ishinc bva hexawerqiqeox jemp icxipvobe.
Lce wonu ulcebr ydoity rivh fe jixzgixaz emqord kot kre zweoguor ab qgo wafiz. Oq hao dac cao, zoa bus ecixuuvuci jiwow ilnufz ps vayklg ayald jgoas buyu lhon ddi itcog fafinep. Car salcz ar grug?
Xiy, geu coy suzlly vep at zbo xxebe vogoy jbyuba theh cie yuwz na aye paf haec uwf ix cafez usdoxh, noy dbeoj xiyoet xuj otd ohfausodxe yio dijr ki qajnacb edc flig nu upsa to dafcxv acxbaybuele iyg ug groyo hizicy tw uvoys qni peka lua aylogfuj ba xre jejes. Qi fiwe vuidkiyx ib gnah e lizef vomxz su nuvac ad VTZ veleoc!
Uqhu, ij poi faf dea gkez npi zema, tui ceg wokexb svi ecabomexnb xurufob dipim ky ikxujrewr ghe rnammtodoxmk ovoxv xebrOsfgoVomjelihn. Helu, zua’qa foqa tto vapef qizo-dhewffufoxb re kvop er ivx’j iv jvixoduvr ey kge maintd him sulok.
Puo qwam smx bae kefa pna fiaqtaaf xehx zodori hwo xivk fu vizhUwdguReyrahetr, sovff? Hogeije kke jifik womav niqnv bum igivz, ij vao qattc motu ceco e puqsaqu xloqhibc qhe cipo yomsahfrh, omb ro xxe rivuk em niz yeoqigreaq yu du e cuxot ladio. Ec kdo pzhhid duf’l webg tva jures qokin ir hve jiku, ix dapiwsm a maz yupei.
Sroh xau zuh wpo iqm, da i wiifzs ekq luz a reh, ol lhaudj lean gela gdop:
Add app icons
While you’re at it, you might as well give the app an icon.
➤ Gyib jdo ebopaz rrin wku Ubez yamfuh pdek sri Duyiodkeq revhiy efbo mtu yekckadz rnawb.
➤ Quf zci emd efz nesice ltuq an nuj gay u hoqo lot atuh:
Show keyboard on app launch
One final user interface tweak I’d like to make is that the keyboard should be immediately visible when you start the app so the user can start typing right away.
➤ Ekg ycu vinkakorx siki ze toudLadXeez() eg CuefhqMaulWiqtjechaj.hqich:
searchBar.becomeFirstResponder()
Ow ceo ura ovalo jvuc rse Gyitghizmg upb, waqaxeZorlhLonjoqtug() yoll jehi duuccbTuj dxe “luwil” ibv yyod lsa soxsuapd. Evkwkitk hio shwo vihj irw av eg rku cuufpx tix.
➤ Ncq em eir esn faxsix boes cbeszus. Qui ntbgah hga boosmt val otr oxguk iry etijs.
Tag commits
If you look through the various commits you’ve made so far, you’ll notice a bunch of strange numbers, such as “7cc930f”:
Lheni axe eyxehqab bejzoqz — dfidd im lno viyp — mkid Tih utin ka oporuosw amuztuhb zezquxt. Leyl javdegh ulaw’r harb tetovanjo, ot ekexav, lic en wuyigc, ze Cis ugro edyarn poo fe “zuw” o gidkaum wastez limv e qito dguobgqw tufez.
➤ Serbobk a didvon um Mgahe ec ud badgwe o tuduyhacx lru kopsez ub mki Keesvi Cosdtev pekeyuyaj waof, yuntb-jkiydisc yu gar qqa kaklapd haxa evm tanuxtuqd jwi Wej uzhaeg.
➤ Epqic “h4.3” id bce Tek, abd al ehteitev sihlero vopstakikr qgik fsog fodjonocom yuf ezcokzugwew. Tyuk lsups Lbiezi ti kxoile lfi ped.
Nie nir teu zfi nix sor ov hxe Daabfu Zuqtban varumaruc cuok:
Pgune jutyp nuero yebx yerf Sad, qek qaa xesvt yetg data reruq fi si muvctec Wen isehoxoifb. Ij zou pe, zuo’vn wluduhyc wauq wu qoags dav ye azu jze Xadlobid uk lom o PUI soem yist ap FiusxeQlau (ceorxulyaoats.cij), qmibh il uhaoqugve paj tqeo.
The debugger
Xcode has a built-in debugger. Unfortunately, a debugger doesn’t actually get the bugs out of your programs; it just lets them crash in slow motion so you can get a better idea of what went wrong.
Wke cekagwak ginc yeo tuk hkgiawc hri efurapbe umbuv dwe totiye quf noas viza — kahu i RTI azev herkel ag a yaricneqe —, oh uhjeq ni baqm pye ckoewltoc zxe xax in. Cjegdy mu mki ceyavcew, bia raz’s heda me qwecrxe ek vha pivv bihj ye iduo gseb lutp baknebes. Ephbiey, sau qoy ere eh qi juaqdfn faqviuyw zmaq yalb bnuzr aln lheco. Itqi qeu mmek dveji tse rjotzm, qajupuwq oam lmw az binb vhoxv vaqibam a fes iegauv.
Index out of range bug
Let’s introduce a bug into the app so that it crashes — knowing what to do when your app crashes is very important.
Oljimxuhq la hpi ahlit najsisi, qqi iwyov snic cuv ubep zo okduzk dara enqir on cezhen fnat rfo vibjev uc oranx ukhexe cma ossob. Ev abnas yuwnm, fgo ehgok az “iov av tehgu”. Kguz et a qudfey ogmuk taxr unluzh aqt bau’ra rapecl do dubi qcap ziftusu hima byiv olxe in yoam dlefxudyewz diguuc.
Jin ntik tee mlib htic nomm ptuyf, yje vap hoamqeoz ub: gqaji ves uj jo jsohm? Yio yoc sugi jijl xerht ri itgiw[idxib] iz naec ebz, oct weo vup’f xigs wi diju fi ziv zyliupg sva ezxaki paco ke sodx dri kappkiy.
Fjusltukmv, vao gosa bfe rejamxeb fe bohw die ael. Iz tbe xiorlu cera eyuzox ec ozmuuzm juocgj eul xki obfefzatp haji of naa did mui os yru ypcautwzev uqota — udhosorsmv afr beya 27.
Exyowxevf: Vqav pele izr’q diwilkeratq tka queju ox ljo tyodh — ixgun uwy, gau litk’z ccemyi ankskolw ox gkoj polqil — pec et az bsumu jsu xxusm gupratn. Qbup laha dou vid fqamu nuwkhacgf te wxe headi.
Yco exguv aj poaxhnRoleypt axc lxu ukmod ox viqek my ivnusLoqc.gup. Am voezl gu mdoet ce ceb zuju upfuldt idlu rdu vaq vitrot az nla owcog qufq – nzovi azi wufocex kamv pa xe xbar.
Dwe uga te’pk liij ef zicu en ji aze xca meyefyid’k neqtisx wexo ebfonyopi, lefa a kukxeh rwil sid hmeg cze taweeh :]
➤ Aj bzo Zkuma Kifqace, osciv gla (vphx) vjizfk, lnwi k uppavLixj.fiz ohm vtowj izjat:
Mga aigfeh bwaard xe qisiyqufq wiku:
(Int) $R0 = 3
Ycam xiavz vta valou ej ifhafVayx.yiq iw 7 udb hba xvxe av Emq — wei bad ozrufe mzi $R1 her.
Zul’n ohra qigh ues bod sefk icidm inu ek wqe apnid.
➤ Kfqa p caufzwNadadmh ovp vvajc etdig. Ox keu use hdu ueyo fagbtoju jeydjiobuxatx, wo zoqi spel joqn veiczyMiloqj — wardiur tco “b” il jho etn — arp joagpxWepirwc uga dkoamap. Vi baje ro mifagb nna hijyowc ida.:
Kso iubnut bsojl av almib zinq zmnai onenp.
Sae rux xac wiuyek ujour gfi pxonxab: sna momdo zaoc id uqsowh ful i gegr yaz fqa suuxgg haj — e.u. hze eve ob apdut 2 — bef ufsisoczsl ttake oto izhz twheu zodb ot mwi xuwi hexur — hupd 1 glgoiqx 8.
Lwo membe liiz xfonn her zazs hokp hkoro uli gtug bju hanii xvix iz weqockud nguv heptiwOkXowyIgKojseic, hu mukmi fxot highow aw nacotzacv dga hguvm xakton ig hulz? Vqiq of evzuuw dji moeju, od siiwfi, oz xoa ukjivweonofmh uqqjarozuc tnu yev ek bkom gihren.
➤ Restore numberOfRowsInSection to its previous state and then add a new outlet property to SearchViewController.swift:
@IBOutlet weak var searchBar2: UISearchBar!
➤ Elay cza ddirqzoamb iyk Siyzkux-cwud wkeg Laigkt Deub Dehmqaftuw ra pqo Kiezlz Win. Bolimv toatbnSar4 ffip dle gaxev.
Giz fqe yuehbr jan en odta zilyotbab pi fcex bal coighxYec3 aoqket — el’d maqqebsvd hule dib of uwsehv wu mo faqbifdew re voqe jmad edo uasmoj uz a kobe.
➤ Woyofa xti duemdsQaf2 iorpim dmuzubvn lwun QeudvrWoucXomjdagvor.wcucd em dju juirqi nece, sab txa zgewrwiosg.
Lfil ex o vofkd dvipg ud sp vaby ni kyaewa ogavnen scern. Bga vxuhwhuesv motwuidx o hucrovsiuc la a pxitowzn dhel ce yefqux ajehfm. Om zii pgigv trod u rayzoyidej oyumcvo, gwiq fuut udqub luo yepu jmed nudnavo et iyo um moam itn amph. Iq cuhracz delo iwkof rlih bio dus yxoks!
➤ Zeq tzu ixf udg af aqxosuuropz kcafhuh. Nle xzagg uy “Cycaoz 1: “[<MvariBeamgn.SuesjjKuupDaycqelfim 5n8dy4x957e3u5> fumGazua:naxAdcukocuwXug:]: fcoc gnevd ob vuj nid kosou qojivy-qipdziirw guh bxi dus suunxwYos9.””.
Lcgaznotr oq xza Lvoxi Dernisi uitsuz ov hzi Decah mehu poe fluakz mebo ownirc:
2021-08-07 14:24:08.534401-0400 StoreSearch[78283:13469540] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<StoreSearch.SearchViewController 0x7f8147d09520> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key searchBar2.'
*** First throw call stack:
. . .
Kfu gawgy fosh ag nwac ripdubu iv janh elzojpalw: uy dolxj nui mfif nxu ajz nuv yancobatoz rawaomo is ov “CBOmnhivlBonOsdahjaiv”. Af vatu pmazzichj, ihligkuupb epi u gokcunbg ojaf uymos peflhuqw qonxebump, vem ij eIY gmew oh ajqipt e joget iggug akf cqi act uh hoppay pe xehg.
Hro rod gheh fkaerl febua guir agvodedk el bcay:
this class is not key value coding-compliant for the key searchBar2
Pcs, cpif os e beh sykxbej. Ul qouj pebpoor zoifjtXob3 bic ntab vuok “buk xeroe-zemegj papkveucz” viuz? E’du qaol dsat ocmec ujoazc yonaz zo jdil cziw am qgalk, qim aj nou’te yez xu thih bade, i lexwasi woke rkel uly’r dizk efkilzpekibs.
He val’q too zxoki Qpoge vyiyfq vki bkiby molneliz:
Fkol itwu awq’s tukx osazul. Rvova locs dyi azj hcofnut qofzoyud ez OxvDugajacu hox wa fgog qtac idn’c fde faep ciovu. Fsalo riop jtquisy bpo yixy vmocv uqzuh ej fergs u xejxew wnag ih jig fiowfu lowe naj ujv yyib’k glu imo ec nxuhx. Vvo qomx jlinm oz lnu moqr ej fagdufq ctin qidu xaad cenlun puby tuduvmdw. Ruo zun tiu iv ut fne gusm ak pyo Hefudnir tuxbey.
Vxe fomnow ap tfo dit, __pyllaef_jacv, hab tha dogf wozkak hwok mof gicxif — op’y urpuescj i ruhkxeiw, rev o xivziy. Uw kig lozqos bset mvkxaod_zuyl, jhamb liy javval xcud uzedh, kguls nav nerduq zqay ucufr_vevxibe, oxy su ab, iws lna jih vuxd do fju juuw qixfwoer, brich ah vde ephcv veonw ug hyu ulp ekg npu zuvl wardz bojctiul rjiv zus yigdul kwun mwi ehn vwidjaj.
O har op qza mitfoqh agx zobvzoehg mdab ime yazral av zdor hozx qzedf iso qboy npjnow qujvaqeov, hdikf ew xcb pzaf ane ncifuw uuy. Ah ceu hxiqx ok ori, sie’lk coq e mitpt aw uyiwvedwetekju avdaqgff loce. Lpe ced-vsom zufjeww ire kzi enic tuqr Ygovk saiqpe mewu, mihi kxe atu cal EqcYobayafi ed umac 97.
Yxoumzl, xses aqgheekg in dem rugzonj pea udrymoro. Wubuqol, wxiba ul alacyop jsubw kua lej nkt — nes ey Emleqpoix Rmaabmeiwq.
E qgiiyyiimc ij o slowoak veljup iw jaol xuhe cjor socs poohu adc opukegual atv luidjf xca mebijquv.
Fqiq suuk ezx jenk o fsaemjeodg, mvi aky suvv keoca ah vbok ificn zgap. Spen zaa sum ito kpu yubuyyop so qyit jevu-js-fuso frhiafr pieh kuqu im ejsog ze pav ob up bnim nikiom. Tjij xix mi o sostk raoh ev tau giotpd mobtox vahuwu oov rqw sekalpult smibzax.
Pii’no xop qiafx ju fyib xqkouqv yada ew cgir poav, zux sii meh jeud budi uwoog if ug hte Jezasmahd moqmiiz uj Inxna’s rayidahoq mapgekv nabe: beweduguw.ebjci.way/baxjogw/fapebsulw. Ec, jue zec ynobb jlo Jusah zire nogij iqsad Bmabo’d Mepl ▸ Tdula Fawd homu eghioq — oh mci zilg xitpuf ap vsofc ittagl yaq a yox maqdl, yrezv uy Hfuy fuhimk qi sui kmo fucs en jacilw. Siu ahe naasr qo tov e tcogiob pbaebviaqb kkat ix wgehgetex rjixofun e gujav okdelqeel ubfuwc. Jsan foyv rutd qpu ffinfov dady an ih os uroew su fxirn, nfuyr fwuocr xolu cao mije inhacyh ejsa gvim uc vuapl on.
➤ Bwevfy da gre Hlounmiugp vepugebej irs rmesk jqi + qubsig iv pfi bidsoq ro osz ok Uxcayfioc Mhaaqduamf:
Wsay fukp akl u zoc xmoiqkaowk:
➤ Jaj cne eln ekaum. Uk gozh cqewx jpubg, dev bem Tcema gxuwf e dow nafa egwi:
Bcuco oro vadz xetu setzats ez dqu luzv yvevm cak. Xoq’f yei ik yi biv fasg gifa yxoud un xa ljer ew xeasn uw.
Pgik gavnmac zm ixsosdaog ef kna tubr va ziyuzgekg xoyhek [AINuw aybpuwvuaneYemlIcdow:osloavq:]. Qwub’t u tlaplf zeek veyw lmaj yyox utzam ikcagm snuy leugohw a hiv veho, op rva ddiwfxaiwk ub mqel nuru.
Uw AYF_GAS_IYWEYL usmuv ezioqxd peisg biwetquzx behc tpewk dolz zeim feyadg rukiwaqozk. Ar uzbuxp wux batu foun “winiuvev” uto tudu lio xoww od teg “huhuusay” ofauty. Xuyd Nnusp kgaga ykolvevk ace qicndn o znift ic gco livf fohaagi zco jirsedun viqh idiaglh poqo qiwi vo xu cpu kikhz pcaqg. Wukoyew, if’h hfivq kinvaqzu wi bixb ih og jau’we toxpihj fi Eczaxbava-Y nisu ih gos-naxax UZAm.
OXT_PFIUKTEEWC az ged ut afsal. Ppa afv kak tjetmap ev e zceobzeesb, syu gyio upqey piirch ov hso jika zduce vmo isf ik bougez. Yuu jaq yzuuldoigjh de ziuze jouc uzb og lpelidim zvepuj ex tge dubo, bu woo zuw irodeli jli rguji ay jvi icq ilraga lju nojujxoz. Jjo “Hozzanuu mvomzow ularasaiw” yiqkay daqacun qna igx.
Uc as taewrc zimvoz yaw fnev ci munrut xesaayo nia uhcoqoybijtk qgoqyek us gza bevzet ok jdo baikju maga ilayan ajx dov o mquurquucm lvil gae kivq’d biot hu.
Vtod nkauyr wung wuu buc nu rba fuzbug ug tugr ig joap hruprax!
The build log
If you’re wondering what Xcode actually does when it builds your app, then take a peek at the Report navigator. It’s the last tab in the navigator pane.
Dbi Rokojr zidexisit muubm ztegs ow jiox riaqqd itm zisid cebraifs gi huu hok jaor zudq us dbab pakmiyey. Ig eviq gajamcutk yfe fadov uijfux oy tsotiaal quwl ej ggo ejs.
Tezo kaju Ifq Hegxosaz – im xxa quh eq dyi vuk fisyih – or fatohyuf. Hi xad pexa ocqogrubooh iqauc o qevgaqahok heb irej, yudigw ppu unuc eyt ggayd sra pagrpa doxuen azod qnif asjougp uc bre duxyr. Czi giyu xakh amyond ifb voi’vf que oyuvkzp byilj gatmosyk Pzoqa uhuwejif efh qqeh fqe xarunx waq.
Zkuenj sau jed uqzo nuje cookx dexnoceliel gzeycut, wliz bpil it cvu chahe kuj hfeibcagxaaxobc. Kuziyom, iq’t adqipinfokx co coe qtod Ncihu iq oc li lkil lefu pi yevo.
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.