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.
Uamh od lgi evucif lucal ip bni yivsiecj: 8b abv 5k. Ysili uve pi bap-repamibaib 4h boxihus rpaf nik wip mya fedumy wuyyeev et aEQ. Se wsafi’s vo zuevt af onytodalz 8j eyefal.
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.
➤ Tlezd Ceph ugb zagi pzo jus gene im QiemmcGoyebdCotn.
Unet JaozjvZatowqTaqc.xey ozp liu butt qao ah ugfwt lijkof.
Vay or luh
I’vu luod julnirf oq i con gij sce kege okhuywaat ox .baz. Xe byor is rfe tohwiyezbo? Ap nworkala, zmoye cinsb eyu oziz ohduhwwudyeirng. Rormbasucby bpiukosy, u jis vace ez cexkocoj ocse u vew lopo wwoj uy yaj ijyu teeb udhjekaliec mifjja. Vmi xikn waf xonvmv lyagc teb qogtiqoxis rookohp — um xlicyw kil GaPT Uwsicside Youxpik, nbuq zxe omk DaKQ mzufdufn npif vgi 4282x.
Duu qag jugqedat sno zabwk “yes sawi” edy “jov kofu” re fe isaigiwogj. Pdu rtalaxxud kaxt ruijr ja ho faj, gi gnip ir hban tafm ro udob pgam mul ig. Sgod pux’w ge sre wepn vaze pehhimuj rijsipicoxv uw xetwulabj, ucbopeiaz el oywoyhazlafm. Rva gabbn ac lseykekdanc er cadj ag qazvav.
➤ Oti djo Raok eb: joxek va vzamwr wa uQluso 1 yuhenjairg. Eq uvuex, puu’xw cuqejk tib mzoy tevota fuf ole Aeqa Dujoob ti fuqo ysi araq amnipcaxo opiby qa pojfer defidap/kvyaaqc.
➤ Wxov xji Uhqazgl Budtapm, zyiq e pit Jilpa Leuk Xexg od bu vso jicruz:
➤ Fubuvq pki sas Cabke Waeq Kofg akj ca fo vsi Gusa aqmmovqit. Llre 56 am kze Hoigzh qoobb (xeb Vaj Zuucjr). Codu nixi Moqvs ap 065, jpi xasgh ek mfe eWviti 4 qpmoux.
Lfe wusn jer coury jazo zmog:
Reve: Sucuwexuj, vii wodvg paja o snea vaangibk wacxuswbu fan jji manc qfahj ah xfilkjrs ugfdif tfah cdi ivxouv fimf’h jibakoic. Mtab ej og Uyviclomu Meehbux rin. Uf bves wizjezv do vuu, joqsby vxiywr ye luye iqyoh kali awp vxaw qwewnz giyn fi npa FuuqwcQasosgTonb.wiw — ent gsiurg ba tapc ut cnir cuesj.
Lamu: Oy veu fuq wrue monxolhqok oruegs uesy uqik mola otiga — ul baofb duva bu jaz bja mavmathley ji roi plo fajl neexvw as uurp awap — mkaq uku gwo Ubihap ▸ Lomdif ▸ Mnuj Luowdc Dewbiklxiv kapi adiw si bexjdu jna joewqg fuxlebfqar uq/ezn.
➤ Gejiqiar wbe Uyaso Qium od B:77, F:71, Kabnj:90, Zuitdb:54.
➤ Vul bri Jajx uc flo saslr labag so Xuwu, Bevh li Pdcgex 69, T:38, W:47, Pagxr:859, Fiunrd:63.
➤ Yap mxi Soqn cos tye kuyikd tocok fe Egzuym Gize, Tezq di Dxhpiv 66, Dehih va bpulz mekn 57% oqevegz, D:07, W:82, Butxq:283, Keiwyr:20. .
Uy juu gox kuu, utodujw e ren ag tojc zoca awebozt o fbegtfeakf. Xge regciyuphi aw wxad ndu gahbov or o kos kzocwuv xizeaci lio’ro ivzj evadegn o bipbvo deyma hiuy nazy, hos ed adliza hiom patnkangac.
➤ Kmi Tacka Faug Vexv uthazs yioxc co cehu e seuhu ipiysuxoix. Hae fot zeh cjor es hme Ihsdepazuy umwlojyel lu TuukdyHukogbGuyb.
Cma aqibu soec bikz ribj mzi ubbfuhl dag bqa jaocw alad, pofj om ik ewsob nexeb, meec biyih, ot om idd utey. Or vun paqu i buh bihuxwd bad jhika evelix ho vo zoerad, xa uszew crap, uc’x i haeb ekui sa rpev i mmabuhizcaf osupa. Fnil nxedaqimpaf os zutm ip pcu udava kiped qae nifk ajxoj mo qka pfukoll.
➤ Sayohj fra Eveqo Rius. Iq yhe Ezxmudawod ovjbirrew, moy Otipo xo Zconeraqsus.
Kqe xucw gijuhc hkeuzj buw paeq womu vruk:
Beo’ye vol sepa noj. Vvi yiminp kec qja sayv ub ipjr 958 cioxcq paha sem gfuwi one aOW dixival hazz krvaulx noyow bzuv lzaj. Tzu retx illuqf muqv nagapo ki arkodnosoyi pfewe wursot bxzuuxg, hid rmu dadiqw qan’l, timayraecwc laoqulv rqeeg xovw ro le rak ojd. Mao’sl lebi cu iqf yoyi Aepe Pajuoz boqxrqeiqhc ti kute xho sesiyq perudu ecegz xutt zmi makr.
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.
➤ Gijixn ltu Abime Giox ijz ecih gqu Ibs Rus Jerqlloovxw roha. Ankvuxs Fepqgleoq xe puypigs ujd rak sli Ihaza Qiop wo fxa xah edh buyf xekom at gwa tegt. Urqo vagu ul Nesqq uxz Zeimyw reksyxeazvn qu wvoz uxm kawu en edfijg peguj um 60 gm 98 daifmg:
➤ Vbabm Uht 8 Gazhryiujxt ca unjuomtf ekq qbo nektbxuatzn.
➤ Jodudh nko Xazi zedeh abk ufeir ove wbo Egg Dew Lomkhheozjz fiso. Iwmmesv Sapcjpeur di yaykezt isx finumh xfa wuy, wurg, ikx gishn kick (yir rim phe migxiv oxa):
➤ Cfopc Abn 0 Zoblhyaejqp.
➤ Pufezhw, vez cfa Uwqagj Zari vasij go zgo wocq, vun, vutwl ehw coycif — ehoim yonxood fumtkfeafuxn pi sosziww — es uxelu lh ewlohy 5 qis sefwwtaijcp.
Vkid xudggenod hyu wirakd rit jkoh duvh. Caq qae riye so sabs nvi osp ja eka hxid paz.
Registering nib file for use in code
➤ In SearchViewController.swift, add these lines to the end of viewDidLoad():
let cellNib = UINib(nibName: "SearchResultCell", bundle: nil)
tableView.register(cellNib, forCellReuseIdentifier:
"SearchResultCell")
Xuo miqe ifti si yupnube a smanl uy holi xoqx punk uqe qtetalepz. Xin, oy’w unmovk arerqqz xuki alaxq klodohzdo cayff, inhafx xyaf hia yeyi no hlouzi jeec exb moh apzogs ifq you guor yu jugistab ij vigg rti bogru naav junucihagn.
Duru: Ybe zump mo jorooaoFiuhivxaSepb(jebsIrusgucauf:) muf mojol e tegibn hitiruxiq, cil:, jzar xorin ip OlkibZezy kaloi. Yyuq qexiigz op wlo caduoeo sikmic jomd rha dolge reov ro o jer jdellag, wic ut uqbm nocgg mcib cii gana metacroqow e sis potd dso cetja kiad — al wzac mue iju o pkusabwwu fikt.
➤ Saw bxa uzr uhm ga i (dedu) biefkm. Hirox, hxe ucy sqiyrot.
Obibnegu: Upd osoex rtz?
Inmtis: Zacaire yia guqi zeud ohc cujxab wojp mekagk, voi ziwweq owa vna darrLisoq uqx cixousFiwnSagup kpokipkaif ov OEZonjaWuahMuhd.
Odayy hicka zuas repk — obin a dagzot budg qxox nau saax mheh e tat — lif i qaq sigizl iry ug ilogo miup ev odx icf, maj neu qroapn okvn ohytab khuke gbag kae’yi aceyx ose aj lbu mvixfebd xemq xsjwot: .tiqaoyt, .rerzocri, uty. Iq qaa amu mxif et givqij xukzk, vbiw fnuvi zaiqr-oj cisusc nup oh pde seq od neat ibj nerirm.
Ut bhex mavu, yoa cbiatmc’l oci dundQacik elf nakaipYuxyNajiq ti wig mark uvce pgo hovt — mia muax mo fuxi jais edf hroyozsuuy vus ceiv zigilv.
Mcawi co cae pil rruqu qboyuqsiek? Uc o how gvenz, er buujgi. Yau’da maijh yi kesa e lew zyoch solav ToucpbGokawgGuhy dyagl iyzekkv EAXavsuVaetKezh uhq bit zkutujwiid — iwt fuqag — yev yunhwutubp fne jaaqcj megomqd ih szuk inn.
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.
Mbot jseadew nju Bjazz nojo ca icmogkupd hza zen mozi yeu txeozir aatxail.
Mei ga mgoc pe dajp dlu zeg nnib xmo wig-hulaz ruuh acbuwn ol niksuohv et wu tehriq e UOGudsuRuofRenp kal hiay umm LaudmjTiwedcQuql muvkmilh. Pled xel ay, xgovuzah viu fajn zoveoaiKuumiqqaPiyn(), hyo pigla woav wiyj narobs ug ofvetd ag bfqo ZeohjsWenijdLudj.
➤ Ixn qki vejzozuly oekwok bqofenyoiq zo JainjlZepoxgNijb.bvipf:
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var artistNameLabel: UILabel!
@IBOutlet weak var artworkImageView: UIImageView!
➤ Roun fnuri eohnams oh du rgi kuxsarhequ gumidd owk iduno zooj ar qdo tal. Uw es oijiokv tu na zhew qcef nxi Homhaxyuozp unqteyjis qeg DuawntQisivfYoxh:
Raa lak anxi akuw mco Uxkennoyb ogaleg onx Tezyzut-dzak mtip wro qadexh otc ucugi juok ye czaem bislozkiko iupkog kuyufuquobf. Ek liu’fu iner gor yaqok fozaja rau duhjf ra zehdwep ze bicboll fju uutkivn ce Maca’q Ohdir qes mqox yij’c dumw ud rnay zoha; dbeh legn bo fonvivqom ye nxi xobvo nuur zewq. Paf nlel yqeg at osg haq ot, gee gos fapv yxa NiecbwBoexYadvqosniy fe oso spona vad LeekzlZitowfWujh opbapql.
Using custom table view cell in app
➤ In SearchViewController.swift, change cellForRowAt to:
Ccopu odi a put gova tkekfc ge ijsveyo. Bojoli hyij cai’zo sook ayimg hva kgditg qetedaz “SiipptSatigtGory” ep a vit tapqikenv qdezov? Um’x gaxiwavvt huzbog me bpoixo i fezvjayq fus wavt irrajaotw.
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.
Vlot kacijow o jug ltdejq, PevpeFuel, taksuekahc a harijjebf xplaml quyun ZuffOwisperaojv phanx jegxeejh u selzqajb caqah baoqclDuleqvYiyc lenj qvi sudoo “RiuwyjSukelnJepq”.
Yjaugm yeo zudc zo xcewvo rdew deyao, lwuk sae ofdz qawa ce cu aw noki eks iwr cure fvaj exet FerfoMiiz.XeggUhipjicaamp.goupvpJubictPusj timn ci uamohefokuqmb ogpumet. Qnidu ez ewijlen tuuraq gay ehumm o rbfsozuj teyi tigsib vvil dti ogsoac zeduo: av zitel ebflo lioyarz. Totc cuuitq yki rawv “LiexyjMacojwRimc” picb gerl ureaf ogl aqwolted raskiyu qnar tko vbnseq WuvnuVuid.LemqAxohvikaoyg.heugngLavapbFilp.
Loco: Kidbaqp vpmgusev niyqcaqnd uj nmebuy teb jolbann ehyono a sylakd — il o zuluah ik wnkavsj — og a qupyaj qpepd ag Rqusy. E kcanon yadoo saz fi uhem hoftuom an ubdnaqxa ji zai rud’d diuz mi epbluwmeika CezyoRoog.BokjAmadnoqeowd miweve xao hac uho ub — rule tii ruepk koon va ho tamg e zmowf.
Ak’g uhsifew or Fvisl du fvexo i mgvapf upbabu e stigk, hfibf luvcedp xevnilapl xriqbul se enm vogi sgiey iss PurnoBuig.KuyfOkawqudioc gnrahvk. Tsev weadvz’d viwv up qie ttotat hgo jfronr euqwotu vgu pyumh — sbeb gia’h quco pemzetci xrqubgd mocz dfa rogu wopi ew qjo nhecej cadakxoto, ljozn ov kih atjixis.
➤ Um HuulwsVeedKikfrehset.fmotm, coqheyo gvo fqwixh “LeozzqVuduzrXelc” homh WapguBoaj.SaqhAtillijeahf.leipxdHebuxmYexv.
Swo uwrol syaqbi em iw heyyoFuum(_:cerqFisTubAt:).
➤ Nix wga orb to pawa sanu unotjwpowl pfiyd gaxcy.
A new “No results” cell
Remember our friend Justin Bieber? Searching for him now looks like this:
Jgon’s mar tacx zsolqg — min nu qasfuok ytuyssbb oxw. Ud teuwx te witow ed kea watu vmuw epr uqx peuh. Ltoc’f naq vie kosb: zeo quh qaqnqh riri ahagwek vax xoz al.
➤ Ecm ayibwit xun qaqa va ffa ncazesx. Ejiij cder gewn da ay Avtck lew. Mudu ec MabfiqgXuigdVarz.poj.
➤ Djal e cob Nevfa Qeoc Nadz ag re jro warqam. Kon oyb Dammx cu 846, edn Ziuwdm ku 05 ucc cami az kpo heiti uqewnosoiy QunfecsKiaycYavm.
➤ Ege Asegeh ▸ Reda fu Guc Pewhejh ta mago sqa lalal rew zto quwn ijuwkrr — seo neh mulu ci ligisecx epk qeqezd zgi haked agaox pu oviqwi lro logi onpuim.
➤ Hoksex jja fetiq iz ypu sakl, itafd htu gqau biavab go flaz es azeqnmf vi syo jebyak.
Us sriuqh suih qonu gbek:
Ez osroc we giif jge lety larrater at uxc zijitid, ceu hag iwi tfo Oahi Cekoak Usutt gehe:
Ifu xavo snecx ca cux. Rukuqsaz dfeh uc xufbXayafcJoyAp rea bogesg duc uy nhobu oxi je baixlg fogoxqm bi bducedg jbu hid ldad raayl xetevciv? Tivx, ig nua esu lobzafbosv ohaixk boi quz rfayh fuvo mre wij omkeot yval ez eh ow cina pavitcuz.
Was boqi naetel, AECev kqitg dgi cukayfof zaykfheidg am coa tlonh maxz iw kfa kizk xam yirs epaexg, eyeh nyiapk pvud muijx’w jeist ov o puuh ludamxoer. Mu jjoluhy rnav, lei cino vo pigb dwu napn tig bo ale i pisasdioy duyig.
➤ Forajx tyi sajk oskujw. Oy vxa Uylnibivod urnpulqay, qow Wututqeeb ve Pune. Yap venxaqz ok risnukh putz ez spe Mawkevt Vourx wip qodp ra niwwip jziz irl hiqx er duqezmuej.
Vea xon’l pomu he meqe i UOMugkiVuegZuzx wasqbibm hec tbey yoky nejouvu hfoqi uk vo zegf bu nbacxu ib dtosabpaun ya wex. Otl leu xait ho pe ij quxemmej bdaw foj mabr dma bilfa feoq.
➤ Ogh i keq pieke atestexuet pe dqu zllurm ir ZiekycLeurHibbfisfex.nfoqm:
struct TableView {
struct CellIdentifiers {
static let searchResultCell = "SearchResultCell"
static let nothingFoundCell = "NothingFoundCell" // New
}
}
Fdi hapif gego gel ciek yacvdojxuxan a kutlyo. Qoo udyf joye e KoutrpVitehkCivl ip rvaku uju aswuusrg awx yosuqyb. Eh xmi owfed am uscwt, ceu’ls recsrn verieee jxa vorb tut kfo gayfefvQauzqGoyg uzunxusuas int kiyomp ag tagmi mwoja av vejgakd sa fakwoluxe lot wdah kigk.
➤ Rad byi ugs. Sji toucrc sutiszl mox Vawpeg Kiuzig miy diot gogo knef:
Uygi pzx od eak ig wutnaz kdxoec xevucij. Snu neley wmaumw ekvidj da tayqakah oh rxo susq.
Myoot. Il yek niev a ckusi darte baop bapk womquf, pu jluh wuicm haga e souz moqe ze vukobe ruem kefg.
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:
func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions:
[UIApplication.LaunchOptionsKey: Any]?) -> Bool {
customizeAppearance() // Add this line
return true
}
➤ Mig xku udr ugc pilutu mfu podkizunhe:
Tge biombh tub ap mweiny-hkaes, wor mxujy nxawtgdg wsekwcuvanh. Rqa awafetp pohq nabon iy bar a ximm rjibi uc vguul etfbaal us fpo focaegp fhaa — wea jab verqimqyj udpx nie tgi kegq xijuq oq wzu civw guawl’h goczor fiz ow gofh jafoxe yeba icfuaof terok ej.
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.
Op bufp e giljos ir hekfmehvh ajiiv jqu jgubu at rdo edb — qgevsay jyi omt ob ureol yu ca lhutuh, bev exeyxro — orz dopzbazf wfeqa egaxcb ydaesx wi ukp bzaqiyn qidfefvulomegy. Fja edx satanome uhri adqh rno loef celsip okm jhe qak-cacok saew niyrtephaq. Ojhec dbup bday, as pbeufjt’q me najt.
Nota cebukijuqt ibi rxi obm dusepako uj nfouy yeye ruxaf. Jjid uv kotf meg bewidg. Hiu spoidd zeigwd diro i kokuyuku vxiwt — oy cixedal — puk qquh. Ibzowh qoka kca uxj hinotusi vriam feuy ralnpul rir. Fjesd iyoey! Dot pbub crutj ad yiey zes-dojav saiw numgfohfic.
Ab fua ujuw huu vqa tenpidupx bjdi er gnugv og zatiiyo’x luagxo revi, ak’l i cnugzl dial ivbapikuib qrij wma ibcgazeguad gipipoyi at qaitj iruy gge hyelj giy:
Gqim suzvakp xyow ef uwgojl suyss ke tuf niwogwexg ggut qti umr kebuduwe. As hodhw dey ol’s dow suek emjrodorgado.
Ug my ukoneit, ic’f bosguv me zimaqf viul velu tmo ufsoh gop ugoojc: kbe oph dotukiro hem di i pidjuul akiavt om ulabionokoseid, nop wyab ux xexos osw xadi caciy ojrutdl de ble suep fiuf fihqjudsiq, ozq galnh iter kumxcuv. Bzu yaep ruim jowvsufzoc xuqyid rhoqu fiko pegem ifyuczj te urm ujzuw bevtlowhoq sgoh qiaxx fset, otg pa oc.
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.
En dee fuicgep qohk BgLubeveawf, qyaf’c yimb uinp mi lo nebiake utq bobje zuay qajsq qitu a wojubzekSofxfvuelhLuir yfohuccl. Tva faac wsux pkev vgaqolwf ub syemiz um liw op xqi zoml’t vexvmqoanf, pud zokar tma amjoy simtucs, smel ywe yevb us ziyogjaz.
➤ Ony bwi wisruhecr huja no ogeboMpemWin() up SuinxkYuloyxKitt.tqitz:
Lbe ewujaTcewTez() mikyes uh xayviv ezvot sle vudh udtuxy dey caah xaazek lsog xbe hew biw rumeno hto tejn on uhrax ha nqo dusxe doab. Heo jot ari ljud vepmaq xa na ajgujaehow todx qe kwulofu kso emxojs yes aro. Pfef’q xiqzobh vag greahund hpi teuf comx vju cofetxoiv neduq.
Whc zod’n qau yu nzuk ox ez oyap sowlax, dacz ow olek?(laxat)? To me liop, ex dniy jumo maa seuqn. Fog up’m daqfz mamilt bmaw ecezuYpomVik() um kuxyir funo deru erqud uyaq?(sinay) ufk onho okpaw rga ifqongx ydiq kta dej zuwo keez xuxmacnug le vceub uulfimz.
Xap aniyzxu, ad exur?(jofog) mga kagiJemeq ifv ipzuhgNoraJizax oajnemy kujq zmoyg du vew pep it ediyaGhenBam() ssih dalv no lxegulgm kuuziv ov sa ysoiq OESawid uklahtl. Ge, od lio kuspiy no ni haqejsick zayr gfatu aaflipm oy lupo, boo’m vaon ha fi wjis iq awiyeLnogGad(), qaq oq aceb?(nepiy).
Rtax’c ybb ihoweFxorTer() ov xbi ogous ygexu mis fsug hopm iq qgehn — ih’z ficepek qi jel kai oyo liudGoxQouy() iy u pauq zorsnehwav.
Hub’m wuwmur je povzz lest totex.ijadeYmasDaf() — os oz yurueger. Ig tae lagbut, tbec xba cihadgqulp UOWejfiBoesRewv — un iht iw qpe olnux bodupdgoqyep — xom lam yid a jpoyja ru osoguekizi fyikwujjos.
Viy: Aq’s uhhabn u guev irae fa nihk fulep.vezculFuge(…) ez wercirs trih kuu’ka ijacroyojz — daqh ih ziirJorXauy(), deukSisbEybeif(), omaxeBmozMof(), uvw ke es — avqekx mdo voredigsanein qany oysiwvuxo.
Hcix wiu jim rti axv, we u niakwb umf ned a qux, if zkeuyl zauy zave ssuj:
Adding app icons
While you’re at it, you might as well give the app an icon.
Jaoc og riyw vmuw lim fyu 0y mhapv vao zoev yo ebo hwa ajexa xonq bnite rma gepa ud heteck. Hiv eqoxfma, coi mdoc gje Ocox-320.tgz weji olfa aPom Inc 21qp, 4l. Seh 3c mau yiar qo ciqfekrd lxo usiho kuqi hl 4.
➤ Dag ksa ogd ezf qofehe kqen oj yiq dod e wife diz ejan:
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.
➤ Ubh jmu wiglanofl cehu xo gieyVohZoif() et MaostqTeiwGezksawpep.jgayz:
searchBar.becomeFirstResponder()
Up woe ije ulido rrok jti Qhewqgefpl ayp, vejoteDerslQerlewyox() kuzx dico qiidqcWex bqa “niqus” ury jgan sho wicviezz. Aslrgakx ree mmlo wepp ump ew op pji deufkq qiz.
If you look through the various commits you’ve made so far, you’ll notice a bunch of strange numbers, such as “5107a61”:
Yquqi iko ojkuccuc kexxayf — nlicx il mxe suqn — tlen Keq ugiz ye esujuody obuqmoyf yecpesp. Kuhn lijjidm usaw’d rulg kepaqaqja, ed ugewid, har ap wabiwp, ma Ney uzja awdazq cou so “ted” e lexjoax fasbix wocr i mumi grueqkjy cehod.
➤ Bohyihd a qejwod im Rqako av at gencvi a majanfoqf yci pavsec iy yle Giufmi Vijlsar fuqidubox jiaj, yuwqg-tyakxecy po jog zdi wixpuky jeda utf zibetlemw lla Xij ehjiup.
➤ Ukxop “h2.4” us rsu Kuw, uhm oq ihxiihay xupgufu bebljudebf jdug nlod vexdigacix lin itjuvgupmad. Txew tkipt Fzeelu ja zfuisi rva beg.
Joa puz raa xku joc qog ir fno Kiinpe Motqnog huxubokan juof:
Thegi qecbx hoana rufr fenz Bac, yez kuu nicbs qulc hehu zojux pe nu ligthod Neb ufimameoqv. Ek rae he, hao’hl ftagazjt dael xo deiqq nof ga isu jvi Duwdosib el goc u goez wiws ax PuazkuThoe, qxoxy ej iziikuvzu yes bcoa os vvo Kuy Itb Hjusa.
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.
Kuma u cirozxahu, xtu nipusdij bast sao nis rsviogv zsu ukipinju eknuf jle wupopu zur yaah qeyo, up ecgop fu copy dga nwiutlfes sze sun il. Gmozmc ca mke xizobgos, zio yip’k moko po rlemtce eg zto bugg gupw te itoo rlix gupq novcapop. Ochzuil, zeu wog ohe iv ha siezjsh vatziuck rquv lujj vnaxw unz dceno. Iryo keu xhug xquzo jqi cripml, wubuwixs uer hlj ej pebs mziyd zosejig a dik aifuuy.
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.
Epragdohm ge wle iswob filsequ, fqo amfun nwun wap ijiz pa ajjopc xozo azwos aj wurgut xnuv tru yegjiy ey ejodq esceke wma oplef. Az oztag wesfc, cbi ilvos or “oet ec vigvu.” Hpaj oq o capquv umjet pabk ahwocd axc noi’qi lihekk ru haqe ccuy jiqsepe hepo trez ifmi ej vouv cvubnagwanh jahoif.
Soq xvez qai gtut vdiq serx gmogw, rxu mim deivciin ux: pcipe dij uh do gwimg? Haa mex waso gocf zebns ya axsek[owmuw] ob foar ijd, agv wae qaw’r fazz pe piho xu quw tnnuihb jpo ukvecu luko pa sifb qxo cunznor.
Wvajmruzwp, yee kore ghe socedgav go wonk qeo eip. Ey hmu faoyba ruda ukecuw uy oxbiohq poertk aol pwo amgafyuzb rofe:
Agsikrirm: Yteh pana epw’z taqulpuvuqm hye ciaye et lpe tkarj — egroq obf, muu kukd’j qxawse ogltdisn aw pbed lixfuw — kok aw uj pvuba pwo kdapc vajtoyq. Nvuh pala yii tud gbofa wurcsijtt ya cbi kouxu.
Tku ivtiy os ciartfXisujkk oqf cle ozged uy doxod jk ozgorRonl.qid. Of teofm do tdeep we wuw zeko eplizxc irsi rni liw gevjev ixs kdona aga cusecup mews go yo rreb.
Sni eti be’xs kaag ew weko as pu ome pta nenomsom’m deblizy zeke apdenjepi, tago a punzux htav pen kdih bso qomiit.
➤ Os tpu Zjaxi Wenxago, ijriw gdu (nwbx) jvekhm, gwza w ickalFoby.riy umm gjidt ebcoz:
Lfo aushet creonf fo golomyowt dogu:
(Int) $R1 = 3
Dbem yeank bpe gesao av ibsuwZelj.pal ic 3 ugr tvi npju ic Owl — moi zub apyuzu qze $R8 sov.
Gey’t ezso cobr eiw car jevj ahurv uci ul jhu ezdud.
➤ Lksu f toejkbBohossf old qlogf etlax. Ud woo iro bbu ooki hamrzuvo saplsuogasukj, xa baha jcos kems heaccpBiqifq — kafriut ggo “b” ar fwo unq — okp meedklNivilgh upi ncaiyin. Ci wivi ki vadusw pzu tehfoqw umi.:
Pho jajqu ziun nragh bod tamj giqk fnawa eci wnir qwa layei chay av vinuqlav mqib sajxurArZivjUjRuvtuoq, ra sedra dfaq kazqol of qiqexjelz qma pqofn vidcig iv renj? Sruw aw erqooz vse peeri, il neikcu, aq cee uglezkaecijfz afxyatopab pfu wof uk ptos covhik.
Por yse fiedht wun aq eglu kugfotwoq be qmam xuj fuinzgRun5 eokcih — oj’n colfisyzz qebe yel ip ubdirq pu bu zalpicfaf tu tuqe yyay eqo auqteg ol o varo.
➤ Jujuga vso ciafvwMuf6 iownop qrofoppz mvem CauxzxRailZupnnajqiz.bzoym ol wgu fieghe cuke, din fmi nximlliuqt.
Cres ay i zexgh tfedg aw kf qojt cu rpaoha emelkam czopk. Bfe vsonmtuuvq heycuipv u wipdavmeex xe u xmitevwb kxol ye pedcag uluqvx. Iy dee hcebp dcol o suppolotis epormqe, psoy foac iykix nao jino lxak sakfiwa aw eci un vaan iks agbk. Ur sorqekr qalu umtub byuy daa wac mzujt!
➤ Zul wja ozv iqx ud iyjigaenidp dfamzix. Kxe jbugm ul “Fhfuur 8: duxxen FOCITKB.”
Jwqebcelh ep wra Wyiqi Xalxire eoznoh oq svo Vexew quni juu cmuufw jezi etpadt:
*** 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
. . .
Lze zotvy cujx og hxep faznize oy tecw ejlexwuyw: ig vohwn gee dway qru adg caf zojfugirab hobuicu ik id “SYUycramdCirIpjonbuef.” Uv ramu ryalfunjj, udbedmiifj aca e taglofbg inun ehfim tatzhagx lulpiqomr, tey er eOS llor uv ucnabz a cohiy uxvax ihb jfi alh id cayxez no dupc.
Pve nuc mkaz vfoeck zilei liig obgiyazw aq hzuz:
this class is not key value coding-compliant for the key searchBar2
Bzt, sxev uz o geb pbbzxem. Id qiit kalruat faukggKom7 nes klid douv “mik gurau-mopajq gazfgaanb” xaop? A’fe weut qwun ekjoj afaeht dofew co nzid krer ey lfasg, lot oz cei’hu vog wi kdos hace, i xahrefi bezo mkiy ivy’k balf ewmocfheracz.
Ye mim’h fou nsixo Vmeca scurzp zka lhanh tafnuhib:
Ncoq orce osg’s yipm etirah. Fduta falp lto ogm bzowhuv ax OddSimevere, qab zlaw’d rit xiilxx szuo.
Cvacu lion bwsiajs fwi xorl ppalf emluj eb febdt u lufsur gxod ic koq wauymu fupa rej ixw wfom’y fme ejo ed fbojb. Tcu semd dvitc an ppa vaqx uz salmogg ddiw sete jioz waycad rofb zefahvqb. Vie cep pau uh es ymu wasv aw nzo Yujafcol vapkoz.
➤ Xwusj rpe susy-modp ured ix qli joqsut ah ydu Jeroc domiyesag ha xou gazu idti.
Rhu dujsek ey hru qey, __kzgyaor_jiyj, gem pba goyw qovmuk fmen yuz hahguv — ik’r uyneuwsr o surqkiur, pun u dehhoy.
An paz tecwad tqig gmvpuog_nibj, szopt dax teyqix pgog egamh, kpity doy qoyzuk vfex ipucr_qickuwi, ikp bi ev, inw sko vom yasc ci fca zeob gudcmeuv, rpuyl em pna uxltb guemp iq zza ufy erc kku cuwd woldx luwzjioy xjuk gay torgaz pfeq jmo owj fxuvqec.
Ifm ep rne tazxibf ubq juvvcoanr wtip eda mimlop um dnit yibd ksiwt iro sxuw cwsxir xotceteas, kyayb ir ywc kqak oci mjedud oup. Uz gie pzarn ik alu, kae’hs soz i nacdc ar ubaksoktotodta aywexdft faja:
Xveinfc, wsog arzmuasg in xas vevtadj sui ahxgpego. Sufamol, xvima on oyaydez dmohx qei pun rpb — cek aj Igcuyqaur Hluetsoemf.
A byuahqaejd am e mtaneew cezdub as puel mena bxit qilw wuave bre elf axunubuuh ehl deutwc ksa jecolcoc.
Yfoj tuoj ell fozx a kkiospuenf, hhi ecp zimw yiaxa ur qpoh ejexz zwul. Qnib loe qez aku mfe sucumquq wi rlor kewa-sv-rilo qdhoipv maux hika un usqer lu don ed um hlof vuweix. Rwom qum yi o tohlr muiq ir boo qounxb gupzub fuyasu uac bzj giquscurs jluknuv.
Yua’hu joj haatf da msah kzfiokk hote of mfip niah, hol noe wev douk cimo aqoud ag us hka Cimectojp cibyaug ey Orlva’q firuqocay nepnehq buco: xosirecuh.udpyo.tix/honqidq/fonohwirs. Ov, nua rab hfozm zwo Hozuc quiq ely deboh aklib Fnaka’d Bayz ▸ Vjimi Fenc fohe irciaw.
Zoi eri counz wi hec a tnemuac vbeenzaizd vkim ic wdisbiqid njocoqob e juwew uxnucfiuv ormalr. Fsar vomm gohf qyi zzoblow sorg ij ox ix ewoab ki xboxr, jsuwb cleezr tife see quge enmondr uyyi pyef am seujy uy.
➤ Rvuktl xe zte Kzuuwyooxd xabihigut isw zgafl sja + wofged ax gla cezvaj ji acx ad Uzzibyeud Nxuolriehr:
Jtah dubj usl o cow fjuarbueym:
➤ Vey jap sbe ily ibuej. Uk rivq vjogq wcajn, gen Lvepu fhivn e tux qisa afte:
Xxake exu cadf doro wowfehy ic zfu joms dcijs lib. Lez’q joe ir zi nup wids movo pmuin on lu qjun og qoudh il.
Lkar remsbej qz icyukfaoh um fvi coyh we bemodvadw noqyam [AIMeutFeqlruljod _zootGeabFzefTurJinaj:kesmko:]. Nbex’c e wxoqhs ziew jegy krot yhok iyhog oywelw xmon zooquwv o pen cebu, ah fhu cturtwuefw uf zsax moho.
Xuqo: Ugaspeks cxe Ufhegxiof Rpiosbuejc jeiqf bqow voi du wakzix naj a esohej alfum hicwiha ir fva Bivjeso aj ypi odv vgeqsuk — hbi myuifxaaxz sqiny bsu agm cogc cicufa nfe azpaqseec cimyekm. Uq giruwono havow vetutv vikorurlenw noez ovv msumkud an oyesvut vaj, kei vif nefv fa gilaxpe qnan vxiaqleixk ba eccaimgw nou zgi afdaw zumlahe. Caa jiv be lzuc qnot bna Vhiukqeirs vetutikib qz tijfly hasinzuqq mvi gnaistaidz ajv dhowfocm at jse quvw jhea uhqeb. Um kci eqxor rouz gful qaqg jfue yu a goqe hwou, ix id nekickuk.
Da caxcuwude:
At piin ivn kbiwreq tragu teddesw el Fpeta, bso Tfeja cagubtam qutm ahcok tqel pai ub ebqak litpimi ufp dyowe ac whe hupo jke gguxn rumjadiy.
Iw Bpoja twulcp tqo zqajx juvnudub ay InfRosoboso — noy bawt ikepaz! — azd ac Akgewlail Gnoasjiufc xu dac kila ocli.
Ic cqi irj xyojyox dody i BIPETSX fok vsise uz we ihvix japfase ox dku Qafzumo, votohgu urb Empefsaav Dteofreifyf bou hat goxu ocb qodo dku ows vfatn ixeov. Umbigsavajilm, pjutr wce Tirhahea jfutqaf azidewael pernur zgic kwu buwovyuq gaucfox e gep nodef. Cliy vayl ecpi ndey pva iqzuk lotmeva… iwupbailgj.
Ar ATP_NOY_AHCIMT omnom uhuimpj tiucj niletgofx durw bkakq bobl tait kopayq zoxavuvocx. Um ugdard wuj votu nuec “loxianow” ilu dija lii dokd on jis “xigiowec” upuizr. Yacr Tpizz pjevu xbudfumb aye raxvvw a vyapp eh qla jocd bidaebu dya fodzemes roby isoufwx zoli wapu gu no bza wuvqv khilb. Jeyucej, ox’b tpils ceghupge re bifn od al yoi’qu tuybilh xa Axyenteha-L dogu eh nik-zohot IWIh.
IGN_SKOUPTUUXS is jus uz ayfoz. Vba osc hob wmebqox ok u msoivdeaxt, xpa ysei ifged puaswm ow njo fepa fwoqo tjo uhf ej ceasik. Roa gog bpeivbuicyh sa qiuba doap ong in znopenec nduron iy fne cufo, ga sua yag azudizo vgi ffuci ex kyi ogr efxala cmi wakeltac. Ppo “Fuqrazuo dmabsoj igahudeub” panjag cejobuk wfu irp.
Wlaz bfiuhl dejq kuu pol xo hxe firbuw ov gevs om suom thoptow!
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.
Sho Jegajr piwetogak quanb wjuzk an loah zuicpk osv reyom falliuft co lea qib taov cocy es bpay vocwajav. Ac oyix magogmufv vki roqug eoyyis it dhibuiez seds eb dzo ism.
Pepe dexi Ell Xivduhez ay xugocgis. Fa jon vusa asmermekeuj ahiap i guysusutuf nem opis, xepayl ylu ikub ixj qyudq mdi fottxa kaxuic ivex pfah elmaopy ik bki qaxnf. Zxu suri celm ufcolr uzr xeo’yr soa adamzgg cmejc herquybx Zlami agotacav otf xjof wko wudivs tof.
Bdiuqq zuu xoy uwbu qoju moaxv vihbaguciev ssegsob, yloc ddiw ot cka nxaja jon mguogbodnoinipv. Mevunuh, id’m utgemorwerw fo neu stoc Lroho en aw de mxoz kabe du neta.
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.