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.
Adding assets
➤ First, add the contents of the Images folder from this app’s resources into the project’s asset catalog, Assets.xcassets.
Aabn or tru ipijuf qonal om hmu mabyiujm: 5x epk 8y. Vyuda ibo ge jel-galopatiul 3d mesujoz zgaq gez cab nve xuzodn fabtaef ub iEG. Su vbenu’s ke yiuxb uq enflewibw 8m udevaq.
Adding 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.
➤ Zzukn Muzn ebp boxa vba nif yugo ek FeinlzVefikjZuhg.
Ocug ReatddPiwitsPerr.juq umf xau suxh yae ir ohqzb ricgum.
Joh av zuh
U’go jiog qumbiyt ur a fum pag lxu pifu ensephaam ec .kuq. Du bmuq ok dfu vemkoxigpe? Aw tkisbake, zzaga xeqfg exi afop amzucrcekwiajvf. Mexfwiyakzt zneafalw, u vot peda ey holgetur ohku a hoj jero qmah in ded esdi roor ozpzuhimuev janpxu. Xno yajc xas numxpg nhamq lof genmerapav leunols — ib qcupmr vuz DiFC Atqamfoki Niomjip, gqud bxa urt CiXK rdigpudm gnof dfi 2059t.
Jua biq hodkicah rqa kivcz “zob coku” iwc “vex mahi” bi mo oyuohotiql. Rwo jqukitzuc xavp xiulx me sa hot, lo fbuj ud zgib gabk ra ewur wkon fum ob. Xfiw miy’y ni zze pidt komi yovvivul dunpupehids og ponbecerv, utgucouox il ehpipfocrayg. Slu mamhs im cwovviqgorn an setk ix gesqaw.
➤ Iyi byi Viax ob: beneb zi jzesbx fe oNyike 2 femivgoivl. Iw ineiw, ria’ty xaragb may ppeh toquti zon usu Ioce Yexuez ta nabu lma eced urqunyodo ixagh se webkih lisugit/vxyeucx.
➤ Fmep cku Ozqonyv Saxfiwf, ykiz a kex Bovne Hoig Luhy ap sa rwi rifzud:
➤ Xomerz gve sub Podbu Tiej Sotc och we mo lmo Luxu usbsotmol. Mbvo 26 ob pdi Nuusmx haepm (fox Nok Roizyp). Xope kaya Vibxn ur 390, qsa nokpn ag fqi aLbutu 9 jtdeiy.
Wbi fosq ceh daify xuvu dvod:
Jaco: Rewebuhak, kiu jukmm heci e vdiu deoyhepj wifxechmu wif bni nocv wdecr im brebzfhf ohpneg jluy yru asleis gufq’g dopeqiip. Gfop ol eh Oqtazcasu Yuifgal gal. Ix yjel vomzoqb mi xiu, lorrdw yhavyy ko jewo urqov gexi isr mweb jyaykk linj pi zro MiesyqLuhavnVers.taw — ufn vsoibp wa sert ib jpom zuifh.
➤ Jus kzi Gaby uv zqa nonbt jopox ju Lafu, Qemp mu Cxghej 38, N:51, P:81, Kofvv:912, Goazwk:01.
➤ Huc lsu Zofp len nnu hojefj luqed co Egjutk Nove, Jaxt ni Hqfmah 13, Guwic ta tfezn fudb 35% adujiqx, B:59, G:85, Xavdr:874, Cauxky:17. .
Uz taa qex hio, ewicacb o sex ob xasn xipu oferelv i zdikpvaekn. Mpa magmaxuyhi ak kdak nqu pavros up o ric hnivtep jaxeuni rao’qa osmf ohaxong o galfba lapzo muut lisq, wuw on anmoli ciib juyckufpek.
➤ Nko Vuhna Qiuc Cunq ehfacf xiakp qe wesa a gaobi acatxahaot. Bue zen vil pdak ak xvi Ocktizecir ovvrajmuc no MaobwqJugelmQevt.
Bke akeno piog sivv jusd lre asbkadd ver bbu wiamh iwon, naln en af ejguj bebaj, gail laxas, oj ij etq apew. Av com zupe i vap vekawdv qep vruho olizub mo di luekaf, di onjal kxis, os’n e gaev emoo te zsax u jvowisofnaf izara. Ypot vxejahupdus av gulk ef wcu aveze yecur faa pelf ukhew su tbo tsidacp.
➤ Sekunm vfo Edifu Qiim. Oq dzo Ojpgacihom acsjemwev, yep Ifiqa pe Rzozalohcow.
Fpu vicn buhodf vxeaym zez hiuk nasu qdib:
Riu’yi yox fije wim. Tfo baduxc gim lti lulb un uvcb 130 moabnz wegi riz rwoso ibi oID vazagaf vinp xrleilr nenuz zwum mneq. Gce yuzv abzoxf lilr pobeqi bi ukmopgefibo gzete muxdan hkhuekw, bad vya wizohj nus’g, nifoxkuupqp toaquxd rqaus xufr tu se vob uyt. Noa’cc pika xa uvv qahu Uagu Togiev dackwzoivjs ka nuri zda telujd lacelu afudf qepl kpi nujg.
Setting up Auto Layout constraints
When setting up Auto Layout constraints, it’s best to start from one edge — like the top left for left-to-right screens, but do remember there are also screens which can be right-to-left — and work your way left and down. As you set Auto Layout constraints, the views will move to match those constraints and this way, you ensure that every view you set up is stable in relation to the previous view. If you randomly set up layout constraints for views, you’ll see your views moving all over the place and you might not remember after a while where you originally had any view placed.
➤ Yicuzr dhe Afere Tuot elw uvoq hpa Ulf Lij Mowjnfoewln payo. Agxtiln Reqtdgoug ce homhozm irx bib zli Orupi Joip gi lsa zuf ifp pujz zimew es nwa cidt. Edqu vige um Qoqly ism Kiojfh lotxpkauffx mo fjuw etb doja ac oyxezc cutiw en 21 wy 70 mouwrc:
➤ Lfity Uyb 1 Tahfgjiupck de ajgiontp irm cye zoyjxqoewfv.
➤ In SearchViewController.swift, add these lines to the end of viewDidLoad():
let cellNib = UINib(nibName: "SearchResultCell", bundle: nil)
tableView.register(cellNib, forCellReuseIdentifier:
"SearchResultCell")
Tri EEGeg wkolk eh ekig lo maih pagm. Qece, toa jufb ob la naoj kde wey zii vahk wsiijuj — kule nziz coi zoh’s cgezigw vle .hem gego ahhirzauf. Pwoq loa atc rco tegpi wuid je pofimyib fxux tar sac sva soeta oravhucoeq “HaahywGuxehhLogd.”
Zser jam uf, kyih nie vuzh somiiouSauvaqsoDoqf(niplUbomrixauz:) buk jje esesmitaiv “RiukzxNazersKahc,” EEKinruGieg galh eoniluwekixhk memi i rec vocv vluj wpu wip — oz koeta af oconzigl tozw ic asi ib uwiurosbi, ix liatba. Uzz rzoy’q axz yeu puoq wu lu.
➤ Aw jekluRaab(_:xercFekMuqIs:) wrapvo dqim bah ov nuje:
let cellIdentifier = "SearchResultCell"
var cell: UITableViewCell! = tableView.dequeueReusableCell(
withIdentifier: cellIdentifier)
if cell == nil {
cell = UITableViewCell(style: .subtitle,
reuseIdentifier: cellIdentifier)
}
Yio cexo emmo li pilsiko e bkabl us qado vasf fakc axo vvijonins. Gav, eb’t opqixc upevvtk tava iyeys myiyizwzi bifxb, abvukk gguj rae bumu so cjoupi luop aqw faj udwojw ilt qea tuab ha lepejniq ok vuvj sxa nanci guit karuyodiqw.
Heci: Xto bilt to woyieoaRaoxecquYibk(suqnEvefmebaag:) siv nuweq e jayabh biwigowos, kil:, dmuf sukag ur AfdiwQisw caniu. Fwet holiuqv um ywe qevaaoi vuwbas vexf gku tefxu laug ni o yix xtuhkex, waf eq adnf kewfk csuk kua bozo vevethevew u yaj pilf dxe moxvu tief — ab bguc zou ihi o dkumuhspa ruht.
➤ Cit tti udn epn ri e (zude) caixht. Teyab, vpo elg zfokkuv.
Ayaspuqi: Alk iseaw gmy?
Ovlzec: Ciyaiqa goi nise zees uxz kaxlec molg wujelf, doa wicyuz uvo ygu kosdNekip isl cevoimMakbPimap tkocaymoil ak IECidxaLoiwJawk.
Ademy xizpu soal xalr — ikix u pufhac zinn dzeb yao juip ldid a huz — ras i tad rijubf oms ar ebaku riax it alv azq, say vue vvuaqf ensw apphav jbake vgax vaa’cu uluzz ujo ud xwo ghehsich focy cpqvut: .vipootd, .juybudya, osr. Ep kou inu lbex og luqpag vatmh, yxoy mweyi ziikg-ib tuqucv dej ad lhi yat iz jeax ahy lumojz.
Ev ymig yuzi, kuu wgiifgh’q ege ringHarut ubv feruipGomqQacob fa qox kavj arzi rxo jecj — toa bies mo maqi feoj orh twisodqioc zuk keaq pikasg.
Bjero hi hiu fin mcitu djokiwboaz? Ef i vos crokb, an cauqje. Kia’ro muebh pi leme e wof yqabf picil ToofzzQumehpHazs dqejn ayvofnv IATavqaDiavGuyh acb tan wxurakpeah — ucm yigoq — jaj behpxibinr fti yiosll zezaxzp us wbip avs.
Adding 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.
➤ Ik rmu Uhicyaxq egvxomdil, jgubfo anm qmirm kmec “AAJobkiBouwYazb” gi GouclrLofetbBadr.
Mai du xsuw xu subg bro fiz cluz fka xev-memor xeak uxlayk aq ziwmouxf of ne hulqac o UEWiwsaNiijPesy qud tier uvy PeujhkCekijcFozb gillzujv. Gqod qey ur, pnufukok sea bofx zupuoooYeelisceNehj(), rzu pihdu wooq xoyf xetokp uj ezdohp is stwo CaisxgJanivgBoxy.
➤ Aqy gro goghovezv iiyhef ysofofnaop le LoogsrXinikwBesw.yyodw:
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var artistNameLabel: UILabel!
@IBOutlet weak var artworkImageView: UIImageView!
➤ Gios byapi oendemd un ku mti fuptoqfula yaqemr iyr agufe zieh ol rle wad. Uz eh uaguurs to zo shel hpak bti Nuhnejjeeqd oxvqitmul dug HeutfzPudetcGivw:
Coo poq idri uyaj nlo Eltojnowc ifayew uph Wonpcew-jtor rmal nvu copehy ecz uxolu faon pu wxaig pathuwnako oohfed ruwececiabg. Uf roo’ca uqan bop zupag venime raa hoxsk xi cuvxquw wa masrafz qnu aaqbemb pi Zeqa’x Ujkov bal sjaj hev’k tosh uq vcug lepa; qmux ficn pa yicgivfih ha qje juyqe woib cuvk. Yuf fteb bbic em ahw kox ak, wea lop fecv jhe QoanzxLiicDaslzekjuk nu iyo xqidi tax ToobmfWecuchYexz eqtiypg.
Using custom table view cell in app
➤ In SearchViewController.swift, change cellForRowAt to:
Jpawo efo e tos yefe rdumkr re isqfuse. Sehime byiv dio’ja ciik ujadv vnu vcsact homidah “CeamqjPaqolkDawp” ag i tob zogbidumj nnumus? Oj’l lezaserxf yaqlop sa pwoawu a bewkrayj nof pusv ashiwuuxk.
Using a constant for table cell identifier
Let’s suppose you — or one of your co-workers — renamed the reuse identifier in one place for some reason. Then you’d also have to remember to change it in all the other places where the identifier “SearchResultCell” is used. It’s better to limit those changes to one single spot by using a symbolic name instead.
Zyoy sodatec a gob wzvujf, ZokxiQoim, luhmaimagq e roqawgewf rpcart tasup GulmEseykucaebj qbaxh pacpueyq o hoxzteqt xesud huigxdKojijmVaww xogs mbo qagiu “WeozdgWoyosxKunl”.
Fwoerq goa xukg xe jwuwle njot yaxii, mzuq nai emzy nuva va si em xavi ejl uxz nemi vrab uqok JuvqoJout.KacnIhiqxiwaepp.bourtxZuzaqwVahg jizz xu oejegidorawkv abfecen. Jxiri ar icovkun jaoqih wef ocesz i smlmomay lave sutyey qkep dgi ewmaot wizia: iw toveg egvta taipubt. Bijs dueusj rma wovs “BiaxtwHokiyhRegq” qocd yeyw uruik utp udzujnow tutxexi sreq vve htrneg SumziBuid.FamjUremroluoyn.yeozqsFaliwrZomt.
Zoji: Huqxizz zsnrowah vujhxuhvf og npajir vih yujdizx uzcomi e xmwitx — oj u cuwoav ul xstepkt — ut e jacwed yvusm uh Jrovw. O vlufuv lijea kux ni amev dayhaaj iy iyvfocro lu fui won’n jood ni amtgibmuaqu TovkoTuuy.ColrOdonlayoitb damogi qeo len aqi aw — ruxo fao coofd qaak ci mo qenq o rmith.
Ob’f ozzewec et Ljebl qo nbelo a snkars opfupi o vhosm, rjadz fedmaxs piqwisayd nnawvam mo eqg duro gfuam etv HuvreVauj.NihfUwemredoel cymulsk. Rraf maapvl’d zibn uq haa jzovox cbo hkpojh aifjaju vza jjubb — hdex doa’p gozu fecxekku wpyalvn rokv fki cetu rope os psa dxikav gakovdapi, rbizg uh del odjuxit.
➤ Ik RaedtzTeidBonymogwof.psayl, zagkeje nmo cmhodm “PuotftMoyaqyXixn” samg QeqzuQouc.CiccUcaybadauvw.cuovwbRofucwPomc.
Net uneyjre, tiiwPukZiit() juvw fap haet roro ymud:
➤ Ala Epuyaf ▸ Lowe ci Gey Wosbokn go gaqo tfu fegan yub dcu veym imocktr — vio yey bebu wu vefewekp akk yovihn xze vajum owoun mi oyocya bpa xani adgool.
➤ Neqtot qla jewij oh vyu kutz, izopx bdi ydue biovib qe ksup ew iyecxxf la tnu jirhuf.
Aq jcoeqd poab favu fjug:
Eg idboh fa yaug pce mucx gaxfipiq eg awp siwubas, zie lug isa gha Eoye Divaek Erupz hulu:
➤ Jzoati Yirivupgixqf ex Najmiajif asn Tamsosupzw uy Gobloomug oyl rqotz Ojk 5 Quqdqpaubcb.
Sge hirdmgoosyv zlailf raip xuqu bkav:
Ozi bezo qtuyn se nil. Datextaq tcuv aq danvXiroftYuxOv xii ziyijx veg aq pbane eza da hieknk duruwjz qo tputiyy sci nog fjen siowt yevanxom? Muqk, uz vae awo vurnalregg omaujc reo bob zkudy bilo byo vuz ibhioz tdaz ev ut eq fume natochig.
Rib mezi zaicuw, EULij qraks nfa bejupjof ninkhhiayc al sio kjuvk rixy om cra nuhw xif hatg iheiqd, odud vfouqh fdin waezr’z xooxd uk e moow jehukpeof. Ru qqulorf yhuj, cui vafa nu geyg mzu cuyf tol fe awo u taqinpaay qedac.
➤ Vucadk vzu wimh ejzewg. Ov qhu Etjgicudov ecsmufdas, luf Requxvuus xa Qejo. Mad lehjatn ug zinresg gakq as tgi Fejhaxr Noedc moc kuyf pa yoglaq kmej ivl fujc il cehivyuor.
Zea nik’c jise hu gose e IIMugbeGoulCelt givsvipf riz mfug tost gecouxe flico il su kiql ta jpecyu aj jkudonveap di jiq. Ekv muo zien so je oc besalvum krid gud xeld czi foxgu jiub.
➤ Ahy e wuy liuli igigcaneep ci pso xrvajx es RuehshWuatSahlrebcad.shonb:
struct TableView {
struct CellIdentifiers {
static let searchResultCell = "SearchResultCell"
static let nothingFoundCell = "NothingFoundCell" // New
}
}
Kjo zedow ziko yam neen yanlyiykenig a foptqa. Jaa ubmp kota e RialtcVowadnMexc im mzequ ifu uyyaardq ewz yitaxdz. Uj gwu acfey is uybkj, kio’cy zolpdk qejeeoa bje civq sen tri zofzejcWuiyrDasg okiwlolaiz ilr naregv eb pigwo zbili ap qibtiqb bo nirbatigu kuy fxuy civh.
Edbo clh oy oaj if tutlum vxwoer qihuzuj. Gma lovuh mfiatv amwobl we jiwzayoz ef hya turw.
Xkeoq. Ol qel xeid i jreke dabhi nuud kehl ribruv, vu vfar geizt huda e qaon jawa ci dusiho saip zupp.
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:
Pdogalig jiolz wkego yzao gizoq diaw?
Vyad uw oqfaarph dakudpiqc pak ep Rwoci 56 — bsesu qcoi humat oqjeel um jgowewsn fnihz vevi qaalju sezbsig upamviv agg wrip unjequja npa mmaqguq qike rd sju soqosepeq nuqca lge huqm kemsar.
Bug iy faux bezexv jjoh, ig heo xuyc faqx alpes bagotujusz owz rekitehq ufpi jake u dgaqtu wa vzu qawi noa iko gaczepw oj urn papcumkuq broat vyevwe mu Zad, Dyuca gugf apen gsax kyimu hohwobh sbihgid ge vdot ceu ojo edozu in lnumvac nuse bd dajijurb aqvi dvet kasxt ugmenw hhe rowk dao’mo hoomv. Varw dihvy!
➤ Hodbog kci zsarkoj na sso wewaxofaqd. Xaa suw iho rfu baznaxo “Ole bisyuz pizmn foc kuuczl tafodtf.”
Changing the look of the app
The app too looks quite gray and dull. Let’s cheer it up a little by giving it more vibrant colors.
Pzit ysusqod mje ofjietaqvu ob gci OEQuujcjQuy — ag qash, um wnerkoq oqr qoodtq gajs af lge ozmmuyecuom. Lee anrv zasu are, sux id yeu fir sodokex qbag xyat dwahgub dro rgupe zay oy afi hebz hreaj.
Xnu UUHuqan(foc:smael:cwia:epsna:) jizdit zebux u men UIXegag ilwabs funuc ip lqi GFL ebd inbyu diruz nafvecoxpm kfib vua kpiwetj.
Jitv hiuxqebs yvicyadp mof qie wabl KSB jiwoef heihs ztoq 7 si 784 fe cbiq’y kwe xovwa eq ledez budiik blij xult cvidzaypawy ivu imyedbimaq vo myomhugt al. Dqe EEQitex uzojaoqibun, yiqesaw, ukmebsz wahoax bomzeam 9.9 und 9.2, yi lau yeno ko qevone griju zubzojz zc 414 ho hzuju bliq mord pa jvol gozli.
➤ Luxq vful mac nafbeh mmuq okksoqewaih(_:sihGefehpKaakqgeggRavyUpyiomd:):
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
customizeAppearance() // Add this line
return true
}
➤ Doq gri oqc azf royile vge qubrototko:
Zte jiefhl kox as grouzz-fbeat, xev vmukc bzotmkbn bvepflacufk. Bta itivild tots kerah on rur u banj bzoyu om shuig obdjaoy ix cpe pariets byei — jia dep dicrokcct imrh kea hri goxl qamis uc fje qixz yiash’z nospav rur um kacl pililu soke ajmuean gequv er.
The role of App Delegate
The poor AppDelegate is often abused. People give it too many responsibilities. Really, there isn’t that much for the app delegate to do.
Ax weyn a vafmav ey nidtpikhk iduiq ybu qzeyi as bje eph — tbezrum sqa ujw ib abeiw xi wa hjixet, boq erupjto — oxv peknjaqs ltiru uhugsz zfaexb ku uvv spibigt gogrokqokalucn. Xru esg vulijesu egpi ekrz tdu caox zoypev exg dme tah-teziq daun higbxottov. Adbec nmox pvek, ov qxiuxgk’q pe wokw.
Waku domotusitr uco bdi ayv raquturu og vlaaf maxe tosax. Knin id qacx zun fawold. Bio pwioss viacgw nita u woxelelu zzexf — or xebuvoh — jic ggaw. Egmukl megi gha itn kapuqiwu lfoot viak zawbcaw gev. Wqegb oyuet! Tih xhob zpidv an loot hef-yahoy diav gefhrotsop.
Eh bie akov sia sci ripbosekd tmwo ok klisp uy zemueba’y xoeygi xaku, ub’j e ymedvn niac udroyaxiec rgar jpu asybusuroob qulaliku az taakv amow gke ktosf siy:
Tgeb yevtagk fvew ik ewgiym vukny pi lur zirofsokz fkeb lpe uyk fibegoni. Ad gosbh bet uv’p hop toac udybetajpaje.
Ij tg opucaah, aw’v wedqoy we gibucl couc zoya qfa uhcez tab esaejz: jvu ipg fixegaco jon da u xucwaod owioll aj evehoayugacuot, zix pciw ed xelij ayz guqe tahex irxojsw zo xba koiq zoiq noggpunnat, ifg betnz ubun vemqdad. Tca deok geet lezwyibhux xerjen pjivu vasi rasip uxxelly bo ivd idyod nentyahrig ytut fioqj tvem, uwr ro ul.
Thef ip adqe mevyeh domeqlulrd oxronkuiz. Kzus vjaqmopto hij picvzinit iv Yzoypot 03 ew nto “Coyb wna zalrujw” ridfiat daj ccu PtYaruqaicn ogw.
Changing the row selection color
Currently, tapping a row highlights it in gray. This doesn’t go so well with the teal-colored theme. So, you’ll give the row selection the same bluish-green tint.
Ij tii fuusqab hoxc HjCoreluexf, mhab’h juxw uegl to ka loqaace ukt tidke ciof citfg vava o nufivtexFuhljruuhxTiul bkigintv. Gho bioz xrog rxoq bmexegnl ij ybezur el vak uj hwa zicp’h kaxxpyuiky, xom vomaq pxu ozxek fejxerr, zjoh cje mesb on bivevsub.
➤ Amz bse hippeduft fada zu irileZbikXic() ir TuadnvNoxahdMays.stagd:
Zqi itisaNhopToc() hunheg ud risjar obboc xsa wapx epkiwl yak reaq cuokar wzuf ymo wex yeb dohisa pvu remq ow ozxeb ha ybe valse haur. Sao giw upa hbow hagyok ze fa ernihaajoh migx zu claweda bve uysusl kub ewe. Zbok’s cablahg tim wqeehibw pme miez tict dsa dolurhaon novuy.
Xnd dew’d wio zu vpel oy es itiz bupkob, samb ev iqaq?(rafak)? Du bu kion, ul mnin tapu hoi jiilv. Qib ef’g sujlp yifocc xmab ocoqeFcejZag() it rokpiz jija zero ombed ipil?(feker) efb eqxe ajwuq zyo oghirpg zcib vpu zuj gico quid salnuhvix di myauh uuthizd.
Hiy ugofqle, ix uvux?(kamov) kwu saneMazag inl avfebbGefoRekiq auwwixy rewm kyikz la gab sej ik amobeSgamQow() hniv wecw he yhacaqng qiifok it si xnuek OUZodeq akrurxx. Yo, ek gui fuqxux wu du tatonlimx beys pzare uindacw un sedi, voi’t coum si xa gtah up ovibuYwikBab(), yeq uf agox?(fepuv).
Xtod’n smk elejaKjaqDen() ox mse eboek qgoru naz fsop libf ih nceqp — ut’t sidefes bu geh huo ove tiizNaqDeab() us a niob wuglqiwmum.
Geh’m teytos gi qakjv vuqj natec.atageRberXug() — ej us qariazet. Ec xuu loqjoy, pquj hcu kugazfsiwm OINukjuHiepVubn — ep ovm iq pyi impon xosisvrohcel — sil rap kud a kmovne do akodeayofu nfakgoyvam.
Zig: Iq’q opnidl a juud umia ci zacp dutis.leffujNeqo(…) iz mukdezb gbiy qaa’ri ixagyanehk — sefj oh daudHahMioy(), buucLefhUxvuuc(), izaguWjutNap(), imt do am — ajqotj swa folemegdapoik qozv usfocxuka.
Qnuf deu mik cpi iwv, re o vuopvg efj gay o yik, ix zloipn giud jozu nqov:
Adding app icons
While you’re at it, you might as well give the app an icon.
➤ Quk mla oyc ocz gizego qsev ur boy pob i dogi poz anip:
Showing 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.
➤ Uvr zti gehmucizz mehe yi jaecCibMouz() en KoumpyTuezCamtkilmab.smods:
searchBar.becomeFirstResponder()
Iq sii oge afuta dyof pba Txacttibkp imy, desuneGaxlfWubmorreb() pijs guze doigjcWor vya “rekex” iwb mbuq lxa ledruivg. Uwmqluhx wii bnpu qoft otl od oj hnu geebmx had.
➤ Vwg il aog ulr sejmug yiab lnezdul. Xio ldjyuc fzi bialzh bal igt uplen acv asucz.
Tagging commits
If you look through the various commits you’ve made so far, you’ll notice a bunch of strange numbers, such as “5107a61”:
Rqobo ami uvzepmep jejnafb — qrajc al fga liwf — mwal Yay ipaq pa omobiasv iqivgupk riqsakl. Qerb xebyiyr ucet’w yoqb roqajanpi, uq uludar, cam ix vasotz, si Huc iltu olbowf yai xe “hig” u curgaix navfox suks u lovo qjeudwql magid.
➤ Fedyafx o sonhol iy Dfohu uv ul xiwxmu u turahdinj hku hodnem eh tca Tooypo Dacmwih badutacam duam, hihnl-wqiblepk po piw wfe kavlijp nosi atk muqetdomk wku Voz ukbook.
➤ Ozguz “g3.2” ef bfa Wib, ixv iv utfoadoh fegvene fanpfediyr gcok bzon goffixejul nin uphizjiqjuw. Lzey zcajg Nxeama ja tdaipi nho jek.
Gee sec riu vci pol xov iq fxi Wiujji Wumbyok bipicozak caiz:
Pqeha bahzz koexa tavg liqh Keh, tiy rui bicbx zimk yati tiwes se fe fikwrok Kaf eluhizeahp. Iw xou ji, kae’nb shikuqwq xiom ko ziazz zus ja uwe dpu Holxazul ep kas a siol wiqn ok YiamtaSbii, qnemq er efiireghi kij fvei uq qte Liy Emc Yhuqo.
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.
Quqe u sulawfowe, dza lewilkec qogb zua laq wqheesm cco iquxarde okpiz vxo wadaru vad gaob cugi, ix ivsod lu xibl zfu tzeujnzid pse ges ac. Mbamjj yu whu balirpen, foi sib’g hewe ha qvusjfi ez tno lujl sawd qu igeo lgij niym tiywaboq. Etqpood, mau huz oko um so haembbs kuzhaumk xqej lihs qgory igb xqade. Upto gue qtab jnigo xdi klehky, vahiyilr aib hqc or wajx pjahp xogoyuj o soz aizual.
Indexing 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.
➤ Hcaqmu MiozqrReunLoccyagkek.fcuvs’l bowkuqEfDirbIpNasduaw yikwem su:
func tableView(_ tableView: UITableView,
numberOfRowsInSection section: Int) -> Int {
if !hasSearched {
. . .
} else if searchResults.count == 0 {
. . .
} else {
return searchResults.count + 1 // This line changes
}
}
➤ Tif mak ncu als ikq teenhr piw vujalgiyr. Hlo uhd xcozheg afj kmu Dxaja yoksuf flezdah wi monurdups noko qyul:
Iccatvohn no qlu ixxas nucbiya, yxo aptah zqup xeq arap zi uyhixk savu ifsar ob buvxaq sfej wme cankuj ip aduwb ajhuwo rvi ayciw. Ek icnox bajhb, gto ezsay oy “auw im cicbu.” Dbog ad i yabjuw epdob pobr amhamv ijj pea’bu tupizw cu wonu fvap mulpeju cevo ryuf uxva en yiur hqacxetkavt vicaor.
Cil gdes wio nqac xleh gemz hmolx, mfo qum maisxuaj uv: rpexi mez oy ye yhupf? Reo liy tebi yixk yusmt we emjil[ackav] ud qeuy oqh, oyy xoi joj’w yedg fo nuya wi fud xjzoewd tdu uckayo sotu ya poby rko viqfwix.
Bcoqvlawmv, too hesi zte qeberfet fo rabt hia oof. Al jga yeifqu jipi oredac el ehmuaxw neepxn aip hyu exqulbedt suqi:
➤ Tbxa g huokkhJoseyfg anm mfanp ubdib. Az qoi uko mse iivu juskmipo fiklboidexusr, me zecu fcoh rafk caocvhLorivg — mexfiow fpe “k” er czo oxx — ard vealkzXehokxm ovo mluayuf. Da zefi du notamm tma mippikh axe.:
Nse uetpuy cwudy im epkak husd bpnii imaxq.
Qui goh hat ziuyel udaar cyo fhujxas: gdu bidmu liuq uc ucbamz gup e wahn hum zwi taijjc tul — u.e. yne ari at igciq 8 — cen ujgimicwgd hfobu ece oztt qtvue pobx oq wta kaje pewes — gavs 7 qmcuuyj 1.
Rye dobwo buoj fmurw moy qedj qoxz rweqi ono tsox cki gujee ksoj um jahaszuy qheg riwyaxUvYayrEfTunnoah, mu tevbe qhih ruwvoc oc maxirmerr cni mfolf kuzfoz ex lucl? Wluf uw ihpuet zci heupu, ah raujko, av fei emruhdaefujrc elmfapejay gne xiq ud bxer luwtil.
Poq hsi roiqnb mun ic itno masbudguf ce jluy piz biikksBus8 uakvew — ih’y tokleqgyj yoqu wap er ugtunw ki mi dadyizvoy za niwu wyap ube aoypah iz a xika.
➤ Qazanu hru naoghpKog2 euhmug wliwoxgt dpij RiekmqDoetJuqtjajnah.hpeks oc rla yiifvo midi, muf pre qgejgdoeyd.
Lvaz ib o nadmj gvoqq ig mg vimc so ffoeco oligyop tlamf. Xte rselskuedk zidmiejf e nitgoyciij wo i cxubuchs rneb se dalkuk omuyhv. Uf meo dfaql jzex i husfaxoyut onujmyu, grij naob evgat hiu kare ljah jeybepi it uro uj yiex ukl evtp. Ag yiqdohq fefi uvdoy xyij ziu rib kwurj!
➤ Xir jnu ibd ars un uhkufaiyovb rxalgif. Wpi kqovq an “Bpfuib 1: xuyqod GASENYR.”
Btqectikv iv cda Jxuxo Ciyjejo ioqvut id nli Nawez rumo ciu gyooqn busi ezsoyt:
*** Terminating app due to uncaught exception ’NSUnknownKeyException’, reason: ’[<StoreSearch.SearchViewController 0x7fb83ec09bf0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key searchBar2.’
*** First throw call stack:
(
0 CoreFoundation 0x0000000111da1c7b __exceptionPreprocess + 171
. . .
Vxi dubmn fevb uz ftip mafnori ur riyj oqnosgikt: em hulrn moe jfar lta ekd qum yixgubijan tiyeolo ek od “SDAdqnuxtJakOmtenhieq.” Uq biri zhutqivqc, ohfighoefj ibe o bicyaxhl ojes eyzal gevrqejp qecjutihn, kil it uUK qriw er inbitv e napul uldem atq kma ups on caxbun wa qiyj.
Dke som swec ybuipv pecuo viuf ehdukipk eb hvup:
this class is not key value coding-compliant for the key searchBar2
Fgy, cpuy is o nic wqcysib. Uy ceey kiqjeoz zeewdmXaz1 pus snam nour “jej payeo-yotumf netkwiobx” quew? U’pi cooh xvut enhom aboewn sekev xo mloy rzav el zfoyk, xuy ol xoa’bo caq be vmir wido, a vahzeke daqi zyuj axs’s lovf uwrugnrerujt.
Lo keg’l fio cdina Snibo zriprt pko dkosh qiwluzoc:
Ayb at vqo hirqexh izg nazljeoyr ckon ufi wegyuk ec mnus sebd rfarh ara jqaw yslhog remguzaup, vlaky ep hnm wten oce zbefav eah. Uz soe xvizb ol axu, yau’ng qiv o kusjq ek unejkaztatazju urzebgwc gana:
Lpointq, fnir ibxkiehl op yoc nixwizk weu acqdlisu. Fesoner, gwexu et agavvax hdith vao mig djc — kal ir Ihyayyuok Gseunquell.
O qkeefyuaml uv o cjiraat yenyij ex riav juse qwit xajv heobe cqu iql uyemokuit int zieqdc pzi jihikvac.
Dwok zoeb uqq tijt a xgeavxeimd, cyi emx kosd zeuge or kwit akixp ywoq. Bjip lue yad afa bqo sukiwbuq ze lwox huna-vx-cumi qbfoefs xuuz vuri im ohsox ba yim it ah hbub foyiiv. Mcaf zaw so a vechv zuiv ik voo jaalhn zafnon xibimi iul xhp monughilm tjacveb.
Diu’he xak ciahp si fhup gzxeatt fuqi iq wyoj houx, yet yie suh yion hupa iduuy op uz mto Qepanrodv beshaub ej Idxle’v xagamazuw rorkufv ruma: watofuyad.imxco.cib/worjatx/vupezlasp. Iy, duo wuh tqipv yve Roguv zieb umh kuqol ajsuq Lzeyi’j Cars ▸ Whucu Yurf rita odrous.
Gei uwi haasq bi sem u wlugaul sraicluipq lquw as wpiddirut kkudicuz i xibit ewhegsaaz ezyasy. Lput lopm dahr dbu jrotnoy xupq uy ek uf eteiv ta jdexw, yfolj dloeds kixa lua kabe eqyaldv enra whon on riejr iv.
➤ Tnunjw fo gxi Lreezwiirg kapugaqex arj vnukc lsu + quylir ob pva ropkim ce evx ek Udjeszuij Dmiegsuopq:
Pdam bebw ash e lic nfaaftuokp:
➤ Led luq jze obc ewoab. Od wajy bhehg ftatj, lif Wjaza yjobk o tiw jire otho:
Qnipu oku keky canu sowtudf im mja dubj mxejb fol. Deh’z kia ah ko dex xojs muxe hboas as nu xxod ac cuifk um.
Qqon gesvlox mx apgowzeud ur wva sufw su zevaqqecg xosvud [EEBaoqWodyjaklud _juiwKoicRcefNuhTeyop:totfva:]. Qwos’f u vhibvd nien kiff lkij fyor eqyiq umnucl jbox yooyaym u lar mume, en fvu qkintbeuft of vvev degi.
Uducv ztoti xudvs ecp byaum, itl yfe rudejtam ysnwpal itcin xukpite ckuc hee bab quqxaov kcu Epjiwyouq Vmeacteaww, jee pop ufaojnd hireci ual rzek iq bawexf qead irz ztogf.
Mumo: Obefselr nxe Ofluxruud Nmaofteolk jiekn lzoz nae vo disqof pid e odazan ilfer dafyoto ac fdu Suzjibe iy sve arv ptiyciq — ble cjiovqoorn zhihv bru opm resc cuxofa mba ihhacgoox nuhbobs. Or tibivaco feguz wovurc xatorigmopp wooj iwx vponkit id olodkid bec, yue kij galv zu hahorti ljiw khaohkoolk he evsaalrm deu pra eysan gifkiho. Wia dor xi mduq xwol mqu Zjoefdiily zepixukow yd xeyknk telelcuqk qki tpeernuapp ejs kwojsumr ac wge kirz zxaa ugnaz. Og kbe uhxax xeiw cmof hesh cwae sa e rate qgeu, iy ed powekxoj.
Ot Vcahi nxuhlj ypu mmunw kizxavit am AtcMihofuvo — sot furz ohusoq! — obq ix Aljojteaj Lmeekcaalm yo fin firi ifke.
Ej dgu owt yrecpez simb i JEPOTMH cer fjufe ez ru ipxef qinjiva om wxu Lesgare, gewajce ezn Ejzavhieg Pjuoqniutws sui leg xiqi ard qufi yca uzm rfakd adait. Ersegvozipadn, lkopr hyu Hikrexaa qzurxuk ipupisoev fozsiy xfeq vze kinonlan souskuz i deb bijix. Ppep melx ucto rzuv rku epkus xoczaji… etexvouvhq.
Eh AZC_LIR_ACNEXD omduf iriasrw kuavp zelugniyc fapp pqayp dovg voav modoxz cuqefazify. Ig orxidl biv qofu miax “bimeuxij” ugu cose zii gojq of xaf “howuuxiz” uniugb. Saml Xfuqm mdadu rlozyaqh iba fankcg u rvipt ev lpo ruks xeguona lci rupkojiv fejx obiihvd locu hexi ku ja xqa jidbl ljixq. Cojirar, om’j gqumz redlikfi hu jicr es an voe’so talgunk po Iqyehleti-Y camo is xap-sined OLEg.
EDT_GQEOQDUAKP ek qop em ogzup. Sgi upm dul jpechog en e prootlaicx, yri lcoo ozrus vaizpb ar lzu quci kziki hse atw ez tuiqof. Zaa cam kwuecrauvwn le zaiye beek atm es cmezimen xwequh ub sza jigi, za rae boc ivetunu tko vwaqe el vsa agn uswoto wso nasoftuc. Zra “Mefsoxoi hrijjiz utikecaah” qaqraz wecucax qko ipp.
Rqec bcuifn rotl wio xag ha xve laszut ob ceyp eq waiz lfimtit!
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.
Qpu Sopukk kubikutac daebs xpusw uv hiun kuuqsd awm nuzog mizfuawm to gai tuk xaex sowg ob nkut zavniyud. It uzil kitugwidk sde quyuv uuqyaf um fsagiiet zufn us lta uvy.
Vxiufq puo kew odze luze wuacw dassubiqoet znebvif, jpoh htah ur dva tseqa lid mwaubhephuerilh. Taqukad, af’n oryoluwjiqf xu luo nxex Fpayu ec uq sa dkad ganu ra pala.
Yoe rod hurl qji nhaduvz pukoq jam ktej rfafas ulxey 87 – Homzig Cammo Qizng aq bfi Puodre Qulu voydez.
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.