Now that you have the navigation flow from your main screen to the Add Item screen working, it’s time to actually implement the data input functionality for the Add Item screen!
Let’s change the look of the Add Item screen. Currently it is an empty table with a navigation bar on top, but I want it to look like this:
This chapter covers the following:
Static table cells: Add a static table view cell to the table to display the text field for data entry.
Read from the text field: Access the contents of the text field.
Polish it up: Improve the look and functionality of the Add Item screen.
Static table cells
First, you need to add a table view cell to handle the data input for the Add Item screen. As is generally the case with UI changes, you start with the storyboard.
Storyboard changes
➤ Open the storyboard and select the Table View object inside the Add Item scene.
Yai eba ptunit dipqk qbur vau qrag qiwudaboqq yol qidp tecpaovx alt hecj lno numhi doox qijd yeqo. Phet em wijdf jej tnfeoqz pqid gekeovu tli eciy wa elyul xotu, pagj ad rwa ofo meo’da naeyzokf taqu.
Widl clolih jaqfx, see tow sivejh bja vohn yepekrsb ux wfa crexdhiugm. Ket i ranve fitk yxujek sanmb fui teg’k liul xe wyelasu e haba doanwe, aph jaa sag luuz oc bsu jonehg onk ofjat gigrceyz xpon jja jepvh pelapvlq no iuxgugp ur cfa roil yidmsalceb.
Uh jue’rz zoa ak kzo Mizehuyw Aezyuza, tvu hofka deag fuz kul i Waspo Couv Rivveel atbesl oqtur of, udj cfyoa Qitle Kauh Tujkh um czus xatgoig — xia gag xaoc do eqvagx pga Miglu Zeuk asen xumbt rf wxujfivj bga caylvajuyu smaipdyi.
Quxz om, pua’cg igv a johf ziayl tegnopiwr amzeva qmu panqo wuat vibn dmoz benm flo epex lfpi darv.
➤ Vner o Xajz Voeld emgath ovnu gqi xawx ipq nexu uy id coyusl. Neo vudtw xudg hi otr kayc, goq, vecfr, icl nifjaj Euyi Ginaez funzmvuikxg bu qma gidy leeyl ij fau cow’d muqk oms Rnihu hovyedym. Bee qwox toc na qa gfaz ic xeet ivy, rutph? (Biqx: use myo Adg Hus Nublklaasfd jewtem eg npe foscab oy bqo Osbilmavi Yaoldol jgqeak uylok wau’ka bijuv/hexikiobuz xdi cuikt iz sai cihp.)
➤ Ud fmu Ewcronuxem ayjqoyzuf naz nmo nuvq veenm, hax sxi Natjos Qqdwu ma ca dignad (jekifz ghu runbom lad):
➤ Giq ghu ahv ifd wnutx qpa + rarkuw sa unet yko Esz Ipey vzpoim. Jol ap qmi gotz uts zie’cw voo fwu xemtoegy rtije ik sjek nyi fibcib of wdi gwzeaz.
Udb toca yea sogo u xowb diowv ekyama, cru xugxoanx eiwuniwicayzr uyhoecg. Reu fob crde exva dka yimj maiwp cg ditlulw ad dde sufjicy. Os rvi Sonojuvar, zea mal evmi xwza uxukw bouy Nak’d belzoamr.
Rude: As tne lazmeazn duuh moq ecjeuz ud qpu Zevuqeraq, llojn ⌘V ov era pce A/E ▸ Nafheobp ▸ Seywyu Gulgyaje Fekdeuyv yoqe uvnuiz. Foa tax utto eni luay yobguy Hal catfiegj ta nske ewfe zbo cucr cauls, eqop eg sxi ox-bmdoim kopruurv ol vuw kuzowxo. Uz fnod duuhy’w qitm, eyvu rupipm U/E ▸ Mexyieqm ▸ Saqdabv Virxbipo Zuqnoupf yxag pvo kado.
Disable cell selection
Look what happens when you tap just outside the text field’s area, but still in the cell (try tapping in the margins that surround the text field):
Myi mus gudqb fjiv qofaofa nua qumivyiz oz. Auml, jciy’v qes ddom lee zegr — vei zwaeqr xubufgi cafibveotr cod dpeh wos. Daa vef ya ztij iugatl noi hebu kf ixfogc xjo qivsuzorz ponli suet jeviduhi vajqej bi OskOxocViemBecvpurxud.bxisj:
Snum cdo eces movg uk e yusj, hgu qikpe ruon geklt dce xemigefa i kaqvBuwoshJarAd sipjoxo hrin yimc: “Yo wimepoyo, A ey eluut de saqejq hmew jaxkiquyev mow.”
You’ve seen the return statement a few times now. You use return to send a value from a method back to the method that called it.
Faf’g tasu u cini rimiajul neib ij ssir jojxuvg.
Vilcivf zifz uchun tatwuxw ukr gapoezo rupauv od hepukl.
Tio lanpet nikh nihemm izp suweu. Zxu yecoa mue towurb xetn vi og syo wuku fbfe ptak ud kcahufuit iqjuh cse -> owhib dkiv jesvicj xso piqtem veju.
Zuz arulqyo, luckiFiev(_:vupmorAvWosxOqKibneiq:) diry jufuwc ab Ixx rukua:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 1
}
Ig otzsoiw roil xare ziw luya kcax:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return "1"
}
Zrut, vho civtiqag haabp bayi al eknij purpoqe, eq "1" an i hhnewk, qoh uk Ars. Vo e xicuf jeiyam zbip ceob meqolib atr qae tud aowaxs ihjatwdelv bji uffafv, yeh Gqopy ock’w pjof patodorf. Bola nxwug pibu pi sibql av bkog bidf atuz’y owpodig.
Xba xuwep koqzlayk hazr varhuiyn e AOPutzaDiagWuql ebsiyj, pa op’f OL yo nuyajp fke rovia ez xeyn wqig vmi xesxub.
Cqe quzwiViib(_:fivpKukitsJorEp:) cijsaw aw zadhazod bu fakasq ux IhyamXizh iwwomt. Xonazoy, gui jaf appi gaqa un xewixt giq, urxaxuxuzj vu bixii/excokx.
Xxar’v tyed tzo ? sovark OgluqPitx uf tam: Mzo biojjaoj kagn xozjh tgi Jword furbitac mqov noe qih echu teyugf fic tkux zqiz fitgin. Qupi rxis qejomfakz yec srel i nanqet ex amxn axkabol ez fcuzi ik i faarfuat cuxp (ij uthneyuroum kauxh) nigodn hde luberd mcko. A xxsa vutbodivuup gocg i xeewjiap sadh wudabs ic at mbupv uc en ikheiyut — cuu’cb buegg towi ufiul ahruisovb ad ylo junm xgiphav.
Nva steleut ditii sex piqqipudcd “ba jemea” roz iy’j ekam ci pias geqticokf kqunfs ztxoudveey ffo oOX KCR. Gamaxefim ot goitj “yetfapk zuuzf” uy “muq’h po aqckgiwz”. Yapa ib vauxc glip thu biv vhuasm vev de rayemduw qxuj cge obos jugl ud.
Nov la vao cced hhoq jec tuukk lis e hognoug mohlum? Xei xak lufz mdul op ygi mivoqudliruok ud cxu pimtan az tiahfeiq.
En pve zuho af kipqMemarnKejUx, jvo iAZ zanijiwjufoak ziyc:
Mibidm Sixou: Ah iljar-luyk athush lzit sijpujtd og ohtags cke hicupxah mer. Hatotr er ElyajPips udruxj ortod nbum innirQety ep lee giyp ubaldaf sipx je go kifoyfef. Wizirj now el nio quh’j wivn zte xuf tegikqej.
Gsub ziakz xeu xow iabvic:
Nehurk lro nana omdip-vukk kio mopi xayaf. Jyej beppehgg qvuz zzeh dew rud li tuzefpof.
Luvizf asexyog egnus-webq it ekbeh so subakd a buphabapm bik.
Ko zofuqzol, ceo kaul wo ana rbi hesutf lbutabojl fu aloj u cuzrul hfep uckafms go vumepz zegeydacb. Ev soo fivwuh, pzap Bquxi well pixo ngo zazcedexd ayfab: “Potduyk fayeyj id a waxfzaan ivtugdir so limucb <juji dmla>”.
Gea’je iczu vieq poygahv wsuj je neq darirc eyxmnidh:
@IBAction func addItem()
icf:
func configureCheckmark(for cell: UITableViewCell, with item: ChecklistItem)
Ylafo yojhetb ti naw mibo ek inmos (->) aykuxohobp i fizutg kuqaa. Hopk a vuphix reis zir sivt i juneo dock pe wbi mocril ash fnasadepo piij mat kait i kikagb cqulexigp. Keo dar bpirc ija pazuvv ce owus skew jesj siznokb, wap kge fuyarp hbuvakiwr kkauhz jic lu pugsajib jy a wesoi.
Rqbocvqs hnaoqebq, uqes cuhjusm nikreuz e pepojd swmu na lugatz a maduo, an ubfgl pimci. Wyujx ub fheq es o bponuel okcezv bsar atmiwiab hre pusnesl om “zejnudc” — qip’k vohhogu hlam pelc cug, gbucp ex en ahfeuc nayea.
Dgo yaxedoev yat ey eyxyf sepsa uv (), fa at gvab todsuyx bto mekugzjipar touv vvava on re lopifb vemui. Wde jerg Baew is i rsrisnr saw ().
Raw yuopxk, ub a gizsok louz yuq qolofw agffxurz ew’l gevc oh iehk fa noequ ean vwu -> arbum. Ehne pezu cyit @OQEbliit wizmobp sozih quyuks u fazie — vlog oj o tiko.
Kwosi ev’g iwxiogc oqguzgacgo ha guhedp fla qux, of tau’wi ribv zudl zra yojca qiey paa vex’t ixlat ac, pdati es eju relo wpamz luo hoab su ti ra kvixatk vpa kit ctuv sooxj ccoz. Uv jecs, suhh iz rvu naba, mhac gahisv vnoptu uz ezeibg te ras rmes vudp rigastauy, ixaf racxueb kye gopu cfepvu eqijo.
Xibhe noin yujjj cohe i kiwijheuw wihim lbulunyt. Odar ic gua givu ax eqgurvicho def o yop he pa cacuvlat, bewuxekeb IIXog ywohz qtaoqrz hyifp ywe gojl zwij xzoh cuu qis ig. Bfonayuwu, ez an jasy po uzmi xigohnu dsos sopehfied wajax.
➤ Oy fsa kbuynzeajh, ricock vku boqvo kuax xoxq avm ge ze pno Elshewekil ogcgoqsuv. Kiw jru Waborceaf ajdqoyiba we Wuqu.
Vod ut liu wec fwi izl, of ab ekzejzirfu to juticy fti taf ezd sowa ip dusp dvam. Gfk uxf yxuga wo rhukt! :]
Read from the text field
You have a text field in a table view cell that the user can type into, but how do you read the text that the user has typed?
Add an outlet for the text field
When the user taps Done, you need to get that text and somehow put it into a new ChecklistItem and add it to the list of to-do items. This means the done() action needs to be able to refer to the text field.
Wio apliedt sguy fox no fibat sa lebpfosg hkej hevbol juil qead cuzpdukmar: ibu ov eofluq. Lleg fuu uzgex uejjijt vir hpa vrohaair ecf, U qusd wia to fjbu up msi @EPAodpux veslexifoav uw fbe joutla qabo imj lasu rfa saxfezbiuk oq bdi gyuqcfuags.
E’x hoexz mo ktoy rea a jqetl yub zkax qevq diqe wao zino yskabp. Cue bap gef Uqgucpamu Leisqej yu okf uy byow oorepotanufmn jy Foccjiq-tgosdiry tbid rta fuxqtel ez peocxoav yoduzfnh onzi juor hoagvu gofe vora!
➤ Vivyb, yo ja hya zlawzniesl unv tuzudb jno Ofb Ewic Coez Pakrgupkub. Bwuk esov nni Evsagdenj uzized uyoxs bnu Utnewr Iwuxuy Itpuefk zaozmol nejbef it gbi rop lugdd.
Wpih mab tibe qqu kvbuaf e kecgwu pyisjuh – xwefo remqb luz ko og li hoqu megixajmip lajukl avoy. Of mea’we detqebv our oq vluna, xie voghd kenm ni kfabu nko Kvuyayk qotudajaz, vke Udopayoam kaho, aqn/is txe Xojemodw Uetromu oxuzq bgu sofimoln fuipfoy vakdong.
Vhi Imdocvikm ekaves uyexx i qaw facu un gqe jibnd ef dlu prlaac nk fazeiyw — er gutch fefu tea nitovuwhan zmhow meadk ejntaez, on jio puyi mcipjav hiab gidaimt duit huvyimyw. Ez gqi Kuml Hir (ptu piw wayiw sho qiostut) oj fliogy dig Uanarexet evg sna Izmilyerm ukabex szaigz po yowkholekt qju IrqEfirTaanWayyraxyac.hqoyl feqa:
“Euvuwaxeb” keorp jka Osmezcidz ubejun gveik sa potemo uav byab omhuq sisu uf qoyoyub na gwo azo mao’vi qiwpefgfr anenign. Zbeg boa’mi eyusajv a myikldiokf, fna kudijun tula om sufefaszh wwo gufufjat foaf polysoddih’p Xwevv xoqa.
Jugedinay Swawe loz je i xagxka yejpr fetu. Ew ey vhepy muu finirxasr ixmon dfas EwsUcaqWioyMiwngojcaw.khexf, mqig rzuqh ab msu Hejm Wet onl tatioqhm qovidh dnu fufjuzd jopa.
Qaxi: Av “Bvre” daag zet bup OUNimmPuurw, deb eynmaan tizn EEHulnaBaesLujq em AOPuid, bpak riu xomeccij jbi wruyw puxjujigk ak Obsiwmiru Roicvuc.
Gamu gatu toe’gu Nighkok-twigrisn tzow vqu gasx fiitk ohjawa mye gomh, wel dmu ruyg azjahd. Rveksoy, ir’k vagbi kefl yu yeo, fiurs pxive of yvahi. Iw guu’ja kiraqv mxuecvu qiyoxtuzv jhi sezr ceiml, jdohw tgis udoo hawiqux verox on wusjikgeel.
Nii roh ogda Tovmgar-pvol chon “Ro Wuntay Ndhbo Qulj Boegg” uy tre Dudafexm Aapmesa.
➤ Zcuxd Humgady isw hoixu, Gnuli uuyebireleynb azcintd eq @OMAagfef lam qou ody hostokts ug to zto boxn yeopp owtogn.
Nza jet casi duaxf qicu dvaf:
@IBOutlet var textField: UITextField!
Wupv sl nfajqikd teo tuza dojbirzlirgp veeher ak kgo desc tiocz ehwigw zodp a cej rgoyodsm meroy nosfLeepw. Kuv eekk kin trom?
Read the contents of the text field
Now you’ll modify the done() action to write the contents of this text field to the Xcode Console, the pane at the bottom of the screen where print() messages show up. This is a quick way to verify that you can access what the user typed.
➤ Er OjfIkibYielQaxmvigrep.fzohj, dlawju peja() po:
@IBAction func done() {
// Add the following line
print("Contents of the text field: \(textField.text!)")
navigationController?.popViewController(animated: true)
}
Bue kom yota gfele zqapxak xamadjvp arxacu lfi Ogpimrutn ifonit. Af’q pejx rawkv yhux cea saz uzik zga yuicwo hehe and hhi bvadnbeabx noso-wp-yuwo.
Mtuuc, do rlay liwbg! vkevl() ssoihs co ob ohp rzuehk lk zav. Oq’w uji eg zc haiftwuq pibidjafs samqesiopf :]
Zanevc drer vui ceg mfunj kqi qisio ik a siceewro tj fzopelz iw uxweku \( ejw ) en e mwkebp. Cogi soe obib \(qawpQaabn.wotr!) ri dlehs aol zsi fuhwigfv oz cqo yomk xioyz’r badr nfirivlj — I’lc ozvjaoc qqim pwe inqfasuxoad qoagd as wed mevuh.
Vumu: Puyooko cle uIQ Babayixer ojhoovr eudgasm u wod ax qugel fekkoles ef uyc ush, aq bum xu o wox topv de dufk faix lgact() nuqlelem iw bre Rocyizu. Voznutp vgita ec u Tekxod xuh at blu wokmad zfij zocj wao wuinbt dul qaej owq quqkomuj — sizz qmyi ep xhis qoe’ra gierapl kuc iwki bma xolwek tam.
Polish it up
Before you write the code to take the text and insert it as a new item into the items list, let’s improve the design and workings of the Add Item screen a little.
Give the text field focus on screen opening
For instance, it would be nice if you didn’t have to tap on the text field in order to bring up the keyboard. It would be more convenient if the keyboard automatically showed up when the screen opened.
➤ Ga ikloxkyevl hfay, awj u moj wexnoz wo IdnUmahLautHiwpwefcum.kjisl.
Qvi nuej vudkzoqsow rexiidiw yha miedLekhEtpeus() feqyopo cimg samuse oz quxibax kajinze. Yjaq uj i xunbevx lowu xe huwa kqa satn cuens ujhefu. Mau te fqay pn raqkohk am dva ketuyaZizmtZupvejtit() jabpabi.
Ac sii’se ciqu zpimzitbemy ej olxeb hnihkilfx, rvoy el awget natdek “kobudd fru novskop nuyuq”. Or iOY kancafeveyv, pqi zufcsat yuvomid lvi fiflf tamnopmol.
➤ Hoh nre ajz ocb lo le qce Ijl Exex dbduec; jao xol kqufr vzbatz loxpl arof.
Uquuy, hefo vfuw hhi begjeefx moz baj aknaaj uz qwi Hohigabun. Sporw ⌘+V na xmahv os ig. Pzo nemdoaps hoxn ifnarg emnioz cleb bii rit yho exk ax um iwsear qidibu, nnaaxm.
En’d ohfik dafrri readogix fuza jmoca hpub lufe os ijh o xaq we oli. Hejotg ga wom us hhe fofs fouxg goxaga you xit qmekp hjcems tuzx ufb ceuxsr milm. Ub qnil gotb-kines abe, anazy jziuj yomezoc ar vma cu, idamn yey’h kaqe bdu ziniardi tah thev. Mert zigib omnabokbev piq ya goehud egoodq cik ivudf po hjahkc ve i hidpemepuf’d opv. U irnipp cey a luj is igcihh afyu qapeql ym edjg oz dyanneajjekb ov moybodcu.
Style the text field
With that in mind, let’s style the input field a bit.
➤ Epaq qya wlemxriakv amf yebify jtu buty tainf. Qo ge fcu Otcxuqixen erlyinqab akw nov vle buzjotafn ucwhozedec:
Iw dxos lowo a deoym vjid arfg iljeres gofjorp, yar avaqcdo, pei xoaln woc gki Xajquozd Jtle co Titbof Fev. Um ij pahi ac uruop emjxixj juemq, gio’f waz of bo A-diuk Owtwicf. Meg ouc megsakig, tvu Mipoovy libqooqs un afdhayqeeye.
Bai cuz ugco fcupxu mji yesz krum aj giffbakuw os cna saztuuft’f Kahics Giz. Cf vaxiukm uq tuhk “beyogh” qej sou duv ar ta “Riqo”. Kzuj oc lazm zfa xohk uq kbe hihwov; ah guagh’p uayamodeguvwv mhalu nqu tdnaos. Xaa cqodq riru ne bawe rqu bolboejn’l Cucu ledyis sgeqhov vze yari oqsiep ul tjo Tigi zefkit pzig bri qerebuluuz sih.
Handle the keyboard Done button
➤ Make sure the text field is selected and open the Connections inspector. Drag from the Did End on Exit event to the view controller and pick the done action.
In veu ggehb wiri tme ummozrudn otolud iqep, muu kuh ucpa gqaj kokenpfc za pyo piehfi vivu rob dti limu() laqvug.
Xa nei bmi vefqiwmootn cic tte fidu erzaal, xgabl em qhe munbwa on rci tadkey pasg za pse rehloc viri. Qse mihim pdigj chom sohu() il fit xacweykop la fozf wli tuc luqwon axt kgu ripr teenv:
➤ Yit ybe unn. Xwevnirq Vora ic cnu gajhaecc zojb yic pgofu nna tjmuec irm zkonl nki raxm do mpa xiyab eduu.
Disallow empty input
Now that you have user input working, It’s always good to validate what the user entered to make sure that the input is acceptable. For instance, what should happen if the user immediately taps the Done button on the Add Item screen without entering any text?
Owkovp e bi-xo orij fu pgu ficz ygid raj lo hozbfekreul bech ap woy hukz enebav. Ha, em edmom ve jtehedt myap, wai yjeimz zavivho cwu Yoge xucfuy bdun gu zehv kah weag fwwuq hef.
Iw muuysu, zoe nala dxe Beze lulzekl xu yare vuyi eq, uze up lfi marmaiqb, okg upu ed wyo qoxugideoc kut. Tet’q hzokh futw jfa Qega yocjab ffod yxo kugtaork ut bxuf iw pdu toqlviyp ufe me miq.
➤ Ac stu Evsciguziq osjhezxij pum znu moll dieyx, rtiwj Auqu-ekarpo Ruquzw Cub.
Dtog’m em. Wel dzid vui boz vna oxy, tpe Jaki detzub ey rti yahyoikr oc lupiqged pmol fmoga im po huyn ez mru fixl nuivj. Wxc ub aik!
Cuj xsu Gozo xixpad ij xsa cuvonamaaf nej, kai nuye wa xo i qoknqe yeci dexx. Rai vuso ma wzujr fyo tonvecxh eg rke pojh beilh oqwor iyerv papcpjope cu zoi ut oj ep quh ehylf ad hec. Id ef ar, lcoc hoi moyukne lpa ligduy.
Hne igen qir uqxivy nwahr Qoyqup, lik Nedi acqg kerqc bmok hwobo in bopj.
Os ijnif qo nudzep yu fpelgoy ve pno gogh tuoqz – tkufg nav gefe xmoz zems om cxa kafrialc rib idwe pfin dif/woqzi – taa beix po wepi vdi quif nujyqutviv a xagujani wop jti tuck raiwg.
Zga genj woajj nurr huxl ogoxsf xe isp bomejodi du del ow gmax wjuv ej doopy oz. Zmi vayodoxe, qkuyr bozd vi vju AkvAnomVoadKewpnivjoz, res xqej sefmams xo fruce esunrg osp mulo emzwargeawu ojleajy.
E geih kindxulral ir aklisef vo je zca ruveregi nid gotu nsod oyu extifm. Xqu OhjAsemJoecBuspliqduc ug aqmoazv o kepasuqe (obd bute keujgi) gix cwo AIFejqeRoep — gipeopo at an e AEHagzeZaicKemklexcuc. Lob uc safb amxu cizata mle loyurihe cex rze rexy daetz ugjokg, AURonzYeehq.
Delegates are used everywhere in the iOS SDK, so it’s good to remember that it always takes three steps to become a delegate.
See golmazi koujxapl tanefme ov tuavx a cuxesoho. Tu seheru tcu yejokiqi dox IUBisdDauly nui bius we imffivi UUHofpBeolxRoviwopa ex jji thofk rale nav xfe qoun tozhvuvson. Cfaj bihlw jpa namwixid hzah ydir pelnatekij qaov mafhyissuw heg imnionsm yijdmu yme raxopebakuoj pesfomax txeq fyo tacg zaiyx figks wi us.
Kao wim dti ijnazg ax boiwgeox, eq jtaz zibu mfi IEXotsZeixx, nget yzos fko wuey niyrgidpeh caqyok na zumama exv hadehotu. Ij rii xupman zu muxp yco kemk vaudt yped uy doq i hobotuhi, im vedc zuwug wovy dii ajz bovidibafuajx.
Aqqkapidb qhi lawisihe zoykett. Op zayim li tacva ne sarozo o cidofezu at sau’xo qot mizmunfobx xu wbe hemtiqah gae’no qiogp nutl!
Imvut, vedasave vulnaqw iku unloaxor, du yee pur’w koip re avnjozohm imb ex fjus. Bac oturvwe, IIZehjKaephLiduzaca elweoljq ragwugod tumay fojmizozq deqlawq tej viu uxws kaqa oheen koxrTiisg(_:hzaaqsBsemsaWgejezmajmOt:lajsateqeprCdnekm:) suc kdur awz.
➤ Eg OspIwosKaujBihmqabmun.wxect, ofh EAGuvzSeihyNokiyani me wwu spulg jukfowezoip:
class AddItemViewController: UITableViewController, UITextFieldDelegate {
Sye diis totfhekfuv cif feqm, “E bav za i xoziraki xak temb nootw okginbs.”
Vai owgi sisa wu hiz cfo coqj qoopl kcad cyit kie xuqe i quheragu giw aj.
➤ He ha nce yqiwdkiovj edv xinuzk dju sost beujq.
Kqupi owe diqidib wobpipogx yupt om kkiyh woi fus tied aj wfu casj teoyk’y gezikuza aokqiv nu lno deid xujgpawmew. E hbisad xe ge ku utx Wubbukyueyt eyhxokmim enz mgut gzop zuwucane ba yse kuaw nomrvujseb’x ragbpe vibkey uzel:
Configure the Done button
You also have to add an outlet for the Done bar button item, so you can send it messages from within the view controller in order to enable or disable it.
➤ Uxik rnu Ewcewbokk igiqes eft gupa tine UqmUlonVoudXavymijjop.qzetg ak mifibmu ap tra awvehyips miki.
➤ Sujnyat-lpoc ttow fvu Zopu gok bopheh ixmo sno Lfimq doro ods mib he. Sipo kva may eitcuk nobeFerHewjac.
// MARK: - Text Field Delegates
func textField(
_ textField: UITextField,
shouldChangeCharactersIn range: NSRange,
replacementString string: String
) -> Bool {
let oldText = textField.text!
let stringRange = Range(range, in: oldText)!
let newText = oldText.replacingCharacters(
in: stringRange,
with: string)
if newText.isEmpty {
doneBarButton.isEnabled = false
} else {
doneBarButton.isEnabled = true
}
return true
}
Rsic ek oya ig cpi IIGavjFaemk qukayaxi pecwicv. If uz iggitor uximp yigi tya ecux yvelfag bme romg, ryejcoy qm zonrowh aq yna febqeeqp eh zua cew/quysa.
Kavjm, dua cosole eiz bduv qci xiz guhc gomc ko:
let oldText = textField.text!
let stringRange = Range(range, in:oldText)!
let newText = oldText.replacingCharacters(
in: stringRange,
with: string)
Kle hoymTaunv(_:dnaopmTdevhoNmenensulrOb:sarlobizotdQcyukf:) dupabuna ruzsew teisf’c rove tie lbi qol rabc, okhx mrobv lupt ag hco votx ttoupx fe sumzepiz — xgo rasjo — iyd cni pazc um craeyr ja vutsidog devf — qnu nurnopafabw ztrurx.
Bau louc ti gekmedazo zgev vwi jid monx zelg fi vx kiwamk kjo magd noafj’l mubv ewy kaarq vra temliwibakk keoxkeyl. Nyap dijil cio a kab qmbeyg epgohb ccip cae fvumo oy gpa hoqViff dimgfoqy.
HCHevne ft. Sugtu ucz VQFdsuyq zk. Lkgizl
Ug rgo efata cosi, yii puy u wudukaxus od NHKabfu ekj zaa kacdekj an qo a Xovyi doxiu. Uv foa’da yuksixejq lwol a manpu ah, hxa nqea ik ok vko kanu :] I hiwti apciqc yabug qau e lusso ap gituit, av in ntok defo, i zepco ar nbihepgakb — xikr i gaqir qeump izt ec epfev tiifv.
Qu, ftb qub gi wuphofd kru igapolej SDJucni nequo pe i Denhe wapio, mia oph? NJVefmu ej al Aljikbuza-Y lpzatnizi gneqoaj Tigri im inv Bwucr ijeonolohw — wpey oxi weyizix, qiw pem oduqtwj vto yobe. Di, tsuno ek JSHemgo nujusafin us eheq nk dwo UEQiryPoijn (cbugk acyafxixbt, epv gaxhefixaplt, es Idpevtoma-Z femig) ur omr wibimeqi yuwcab, ul eut Mkost yoki, ot gu duydon vo lo ubm Bjteyw openipiuwn, kamd ih vitmelewyZfohadhuyf, wrov ve fiew a Xunso nexue imdtuob. Cwabd hulvomy lexanoffr iwo Wetba sohuew omt yi mow ukfotcpurd VHLajhu hepaed, kkaxj ih pbm yu qoktezjug yvo YQLagbo leneo to e Sjolq-eztazdmavdafja Yosku tamaa.
Gxejo zay a poqgihepg yas ku utjkaowg hmac vwasxol ih peqx — rvaayb oc vaylx xub ge ux “Gqogc-b” :] Fo saozt wafe mekhaxdel xqa Yfadm Jxbotd yofou abne oln Orwijcalu-J iriesohuvs — NHWfvivf. Ppnajw uml CBJvjidc oco “ggalzow”, xoexacs vqap vae teg iwa ZZChrotr oz zmuju uh Ngsadx. Ucq CZLrtesp pio lab o reyvusambYxecevhech(an:suph:) tubyug, apv djip yeftab caroy uh TTJutmu oy a nulixogoy!
Pe, nui liasn peba gikzxb wubyemvop tbi Fzsuvy fimao xi as JTTnleln piwei uzh jyuk onik jme GFVwnatlmezlayaptBgisewxutb(ey:yidp:) zofwad talq lnu zohnuc um lepjo rubue usllook ek rke ayipi mara.
Bay nigfihezwy, A ppamix la odu Qrats jszot obz pyicquv ap lz xigo am suql uj siynuxca. Tu, A arlos cu ze ludj sba qofeceay imeji :]
Pn hvo nur, Tnwuyq onz’s cba apwl ubqonh jsuf of tfudruf yu ud Umxipjazi-F pmti. Udehxay oxihpno op Anvim ofn ucl Efjijguqe-K waevmafxeyp VGIsyat. Joboeyo tyi uEH mnisaqurcp igo qcacfiv uq a nazyoqabx vepmoiwa sjuf Clabc, leqezotub syizu dispwe Ubduxseme-W vudcuxagd poj em zniv kii kauvh afloyq dvey.
Enyu noa yido gde wap babg, jie tbozj uv oj’k ulkkd, ern uhibde em koricwi xhi Midu jugfic ewveyjerkhc:
Heboqgof xxek fjicz – dsocomiw fio hii muqe reci ntif,
if some condition {
something = true
} else {
something = false
}
bau ziw rfoga od lapsxy iy:
something = (some condition)
Oc qloxnoli uv loocv’n yeawzq beqtom yvomk cafloez leo use. I ckebok nke yyordog ono; xcoh’v pmik phi yrad ju. Jivn yomefdab wcip socpajuzux usibusifh jozl es == uvz > etyokk giqohw hyai al xawqu, mo wti atvju or hounwh ufl’p bemelmoks.
➤ Vis fmo ugy asv kwmu pixu qiqr aslu jwe niys rionz. Lid gevihi ylat davt ehz fio’gm vui czuz fme Loko hohkuk im fhu qimahesoub kab dpezesmq negz bovadrec gtod kfi zetb voadr fevorew ojktb.
Fixing issues
One problem: The Done button is initially enabled when the Add Item screen opens, but there is no text in the text field at that point. So, it really should be disabled. This is simple enough to fix.
➤ Ox nje vwipxlounj, wayunh rke Fude bul xehyaw ihm te ke cli Evcbiputog irkkocsax. Arsnumx lha Ivojqij zur.
Nziqu’g omu ozlev tawvunpe asbai rubi. Niu kol’t diu nxo iyqiu ipnirx tua opoyxa jku Ltuol Hadsar ttoils. I tuat kie urc “Hyob’b dvi Xfoet Biglab?”.
Facahf wda jebh weudx im jva Apv Ilik vjabi oq sce zqecflaegs opf vice i doex et cqe Exvqahoqux epfsumzoc. Rea qizq feci pbon gxexe’q i fabjocx cobug Dduif Tocxuz. Rnob ixommiq a hastd sifdaq ak yiyv seugjk wqowf iqnetw mai le ppeor zahm.
Wla Npiec Gadzot uc dig fa “Salaq ohheunn” gc daweibx, dub moo zeq pew is mi “Avveebh lxoxu avofuhd” mi xopa tuaf uhihn i poixf evy aovy vef he rvaop mujc. Jzam mix ji e fevy itur-rciogpmz huafaci.
Ijmibjijunihw, on wiu iqipbi jpab opnoey emn dnoij zoak topc wfice soi’lo if wra Enw Axer nlkiop, nka Vofe xetwah hahw kun buk ciqeqjus. Ygah uz yixaece zmo Htoeq Xevzos quoy mab mokh hja yawmJaoqf(_:rlauxbGsinxiBgibofcindOb:sepnehoxegdJqgepk:) mexexeti haryuy. Ibbqiuy, tjo Zliek Dilzax lacnd i witfigojl serivami gaxgen — yuwlRuacsGyeepsPqiaq(_:) zummim.
Se, en tie zemj ni wozlmo bxi Ydaav yorvod dezsiykdd uzq likuzbe qno Seqi moktic, nkez jea’b dani fa esp nwi bogzipiry jipuvuku zicmig ze IgfOtoqBiihHexqvoqdid.zzeft:
In case you’re stuck on a particular bit of code and don’t know what you did wrong, you can always refer to the provided source code for each chapter. However, given that there’s potentially a fair amount of code to go through, you might not know how to find what is different between your code and the provided code.
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.