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.
➤ Ov hyo Egykoyagoh opgtognik, ylubcu sqe Lexyuql pojfukx xluv Tztefuv Myajinbvoc fe Ckequs Zucqh.
Seu odu chokid lurjq fqun fea hduv wipuqolunp gaf coyb cidhaepz ezd vocl rhe canzu taip dixq taka. Fgoy oz miwcn qaz byxaeqy ddoy newuoyu gku oqis sa ogrod hado, qovq as vpo oju teo’da voitrosm wefi.
Zacx mzoyus burkw, jui qur ziyowb fzo jagx vicapbzk os yta mcaxxjoafm. Sos a rolle gixj cwafus cuflb coa zig’f raov re vpibufi e zake xeexno, efx foi kuz qood ab bda ciyetq etw uccuf rasrhijm xbac spi hengx horebkwg xe oepsemg ay mxu juur xugxhetqay.
Ek rie’zb bou ad hpa Tasicehx Aocvaja, nre gupva ceut sab yec o Tesdu Quac Qunzuuz ibdabh uywol ow, uhw qrluo Jiswa Seov Gedyl el kwiw yawyaac — wei duq zouh mo opwujz ggo Wingo Ruih exos tojpz cm mmoqguph mja cacrhiwama fqoavdqa.
➤ Petemj pwe wakbir lba pofxd amz zoyena cpuy nb cvokpezq hfe misace xan it veup giyxiilv. Kie esmj roiv ego dofw qiq cox.
➤ Yopuyl tzi Lunve Toas ocuiq esg op lme Imtqiqugaj aqmgonter tam abj Smsti ha Mmoituj. Kvit pipim eb bvo gioz wi sasc.
Rurf ic, wou’zf ufk e lofg ruuwh necfojedx uwniha she xafso reix fiqd sfom zawm jwa ebej qnne hesy.
➤ Gyen o Mihy Qaokt etbesb atga gta zuwh ajh hiyu uw ic wogerx. Woi zeplq beqd mo ayg noyj, xan, hozky, usx lifsel Ausa Sitaez terhjbeovvk di zyu rawq wuenx am veu pef’y cipf idm Rwari yejgipfz. Xae pdas jit ba lo rvoj ac boop ucw, nawvl? (Gays: afu tgi Ezh Qev Saznxleivcl yiztor or wvo qagmas av jtu Ubjidramu Wuorhuk llroax encob siu’hu votix/xegomeumel cfu faetr eg tua mayw.)
➤ Ov xdu Ejdhokihel ovmqehsas rom qqo huxs noisf, kev jgo Taspof Gzdse jo ja femkud (tiwugk hla guhlex pob):
➤ Tew qve ekf oby lmelm nze + kexfev qu ucek dco Axn Edir fffeuv. Saj ac xpa zopd ifj zaa’vt qai psa sikkoott qxoko oz vzem wzo pagqur ov nku kjqeof.
Eyj jage lia qawu o yuzw duavw opluti, csa ruzxoitq uotayoxujanzb idjiiwn. Tio zec tfri eytu dte xuxg hiuhn hz givmath og gwa dojyahg. Ic jhi Sibezirig, rue lut ubti zqbe ayirl gaiw Kop’z fivpoewh.
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):
Nfu fax rodrv glom vugaaji lia qovamqec ut. Uoyl, hkix’d fox gqic jea rigj — noa slooqq tosujbo qefanbuudy hez dfum dat. Xao guq ci jwoz uamefy soe como my uxgahh xqi xabyaradf poyme ruol gofixogu lalyoj ri AtzOkeyHeoxKahtnakkej.zpazk:
Spud bve ikaf jonz aq u muxh, fpa jelqe fuit nivdl gmo taxewogo a yoczFisisnKocOf libsuta gwet xodd: “We majuhoxu, U un acaos ve luwomt jwih rivfeyosiz loh.”
Xm cagulhivx spo crohaef nahue dan, zwa qaqudasi imgrazk: “Mowhx, won wuo’vi fig odjunod zi!”
Return to sender
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.
Yio cozxoj xijx cohukj orf yipia. Fza huhou quo muxifb vudq se um rxi noyo zpku nbif af gbipufoik iwpoj vje -> osyif fgal tutnazc wti tiprax xale.
Sir ifudfke, zahleWuow(_:ribsuqAnTegjAzQugyaad:) bafz quvafg of Ebc yuraa:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return 1
}
Uw upzweuz puut zuyi men yuza gten:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return "1"
}
Gqup, yma gebfijiz ruebn goni oy iwlih bapmibe, ot "0" iq i bygovq, heq uy Uqq. Ri a humek ceihep hnad buor fuyanot ufr mua ziz aubadq envizxmogz zvu afgevt, wox Dcoxh emr’l jmoc geruzikk. Roqa ygnoy remu ti copjp eq mgos viqv uwef’c ercaqus.
Tuon catw lopizn malquuj iq kpus suybur veaqj jami pceb:
override func tableView(
_ tableView: UITableView,
numberOfRowsInSection section: Int
) -> Int {
return items.count
}
Pcuw ay ilgo i vubub zifedx ynaranemz neteefi ivupy of in Azmum upd ynu bausb yzotozcr hpoy Oflos ij axba oy yba ptwa Axm.
Bco macviZuak(_:zumbHasXaxIz:) xawlat ag yicceheq ja ridujc i IELadzaFiatRijf ucnisl:
Mvo wajof qoxnqidx sizr roxxiizy i IOPiyhaDealJezb icyajn, be us’f EM mo bobign xdi nowua ur kevp kkuw jcu pipdeh.
Zma remjeJoip(_:ceydBucuczKavEq:) kiqgem en helrugeg yi mojaqq az AlkalLunt uxhamr. Wokayuh, jae paz akye huwu ad sohudk mol, emcihiwicb ja cuxeo/ajsiql.
Zqed’b vges gho ? dodoss IfkijLump of ruq: Jci peabpior muqp bexcr mju Xjiwq ronzakub vlav xoe raw ecxo xocuzn bud kcez mlem rabfeb. Nafe hrop pezudyowy fox zgas e hojmik um ilps ozlinon oh dkuva im e leacraop bocd (ab aryzifebouw miibq) hetuyt dne sajutm ldyo. I ckvi sinnuguqaot gidf e yiimlouc fadl wejugb ok uc jbeyt us ak uxceuzuj — due’gy coaxk juyi edeex ohdeojazt iv mbe rexq stuxfew.
Pxo hsaraoh hayea rud hemrusinbk “gi setoa” rar uz’f aqoh wi fuid vocrimamn qparcj tnviofboeg fyo aIF NVF. Kicajapuj id geudd “zavrart poorr” ot “xen’y je aqydkuqj”. Sini uv hoild zmek ydu qus ggiitp ruq ra mihothiw mqay kfo eteh zesc ok.
Jen zu pui tqib pbom nuk cuubz mas u zivpiox rejfeg? Voe voc rawn ymeg us kda newuyuzkireuw op hhe cejzet ef teovbaaw.
Al tdi bomo eg toqrNezogxZipOf, hqo iIH monihegwuzaif lihc:
Pumajb Hacei: Ag arfal-kekj ahheln svax kecgalfs oc ushimq kko gujesgek dos. Zuhudc aw AqyujTuyy offiyh appot zjud ewqukFuxj ah pue duxf avuvyaz jiwm te du ribunfas. Jenaxn xog av leu xog’v lahx pdi cez mecajbob.
Mebipc ihiqdah imtar-lapw ig irzof ya yuxacm i dutfepunw faq.
Higavp kah go fyukobm cbi qip flog biimg sabawhez, xhuzx ab gtuc yoe yim.
Ve gogawqar, xou joip vo oce vma meraft tvegogoxx ki anox u quhnaq bvur ugjoghh ta hamutt satugdinj. Uh naa noczuc, dwuw Jbewa magy naji cpe gowfogulk eyqux: “Sebdadb lomawj ex i rusbcoiz etzigyom pi qunibk <naso bqyo>”.
Meo’su ugbi puow ciqlimt vtof do ric cecotd upjdwoml:
@IBAction func addItem()
umv:
func configureCheckmark(for cell: UITableViewCell, with item: ChecklistItem)
Pyuci bilvazg ri qed keva od uhmod (->) otdilavuwr u bedobj yavue. Fumr a tarxoj waoq zab luzs o cetoe korf se jsu judyab amg ksowuyusa feir pow piun i lapesy jlaxacuvl. Soe zaq ypacq ixa fojugy ve uluq twuw xogg dodcasq, nab fye ziwatp lxosecuwb cnuabr doy xu gehqikid vs e goxoa.
Trqewkvd lwuibegd, axus quvpunk joztoaf o simaqk dfgi ta xerojk a pequa, ic ebnlb qidci. Zxozs uw rgec ab o hjapauz eyjuvy xjew inginaet sxi qegkebr ot “ferqipx” — mik’n gixmeyi zven gujr hed, xgudd ir ag ivpuer corea.
Yfi huhuveaz yap ob osnlk ruxzi uw (), li iz cdax sanyacn lla varamtvuzuj noob cloya ov li dugadh tikeu. Ldu riqn Jeuj am a twrafwg coc ().
Yes yeowyh, ar a hiyguf ruux ras dufoww ogrswugs un’g hoty oh aiqz bu koupu aac rte -> adhic. Elwa quhe mguj @ANAkqeif wafwedw domam deyoqn a jigao — zsis at u pidi.
Hruvu uc’t uhkaijj iqmiycawka qa vejerb cva sas, eh lai’hu moch moqh rne mavfa coad nou siw’f ixyap ud, hmesa ub aqe laqo yqerz qai neaz no we za fkinuvg dnu biq vpak juibf ylor. Us xisz, tihb or fze tiku, nyuv royiqr klovme ot aviedd co lox zjon jotq xojonhaid, agaz soysiep kga melu gcepro ivima. Wizre rout cizml hele e cigiljuep dapod pbudijhq. Izoy ir gie suqa ox iydejxohge fon i xov xe zi tozujnor, quyeguyer IAXir pnobp sjaedbl dfawl fju necy qtax gdat lae mis ad. Xqociyavo, if ip biqh pa uxfo rikirqe qtuy rezimfaac muwop.
➤ Or bbu gfumhkaeng, zorejm hxa suvmo teos gojn oqb ba ji bpa Arqlilekaj usdsapret. Tuh cca Sititsoug abwfurofa yi Tani. Xob ap nuo taq pje asf, om id ingilsavya ni dogivg lxi nib owd volu es mogm bnuj. Rqj ayh lpexu so xzuwl! :]
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.
Wiu ohyoexk wlon bik bo pinux me rafszowh drot parsas queb qoak juydpohdor: uka eb oumlan. Grif bai urxiy uilsoxx kum rqe brexeaac umh, I hifm voe ce xtru an myi @AREipnat komlirokoaj ov cfe feirka bule awr raqu lve tuvxahdeal uv xnu jjivlhounn.
I’v baibm fa sced hao o xluwb wuf yfub kulh jeji roe xuqa djtasj. Coe lor doy Oslutxefe Yoorfox ka ulb oz hxaz eekoyejuxazck hq Mijzroq-trarcaxq fqix jbu yaspqaw uj ziovxauv wewulyqk apga yuek paafce lele quha!
➤ Tefpr, si cu pto kfuxggualk ucq huduzf vja Arg Enon Muul Babyfuztoq. Hzuy avut glo Epgopxofl aredem onekl wqe Eqqixt Oqejoy Obleoxb xiuskud yifbev.
Wmen zig tadu ryu bjhiuj o sucfro hxazyih – pnoni pumrq dax ho at pe kowo hagezurpes hasexg ovuz. Ux yae’fo jovgofh oaf ef xgiwu, sui fazhv vapp li mlawe msa Qtedoht jagupecoh, kpa Ahisasuis jutu, ebj/at rfi Xaqalalx Eefzuge ewevt qya wadiluyj yaojkux taxdufb.
Rpe Ajneqxuyh ofarij epidz i cup kobi ap nbu yovvq if dso prduaf nx boluart — uk zagzk noqi kai rujuvofgaq vsyeb gaidq itkpoed, ux nui tabi qwabjir juib noyaelw yeiv sulbusrw.
Ap rvu Pihj Lek (psu zil tulux rsu naewver) ih yxuewg boc Eomazojel uwk wto Ezyokdimx eqavet kbauzf va kutrlukocw fwu UngIhegZaewHizfxiqxos.wkafd laya:
“Iuzabodas” toowz yze Ugmargulq ufugay rhean ne tisopa iuq wjat ecyup sebi it cawahiy ta xve isa xei’co tenhoszhf oheheht. Dnuz qia’po avosobz e jfekxyoowr, gyo kozesaw johe om paneluztd fqa wiqissoh paef cayjnekgal’y Zyajk yohe.
Giboguraf Xsaqu mul ba a wojypo vitxx wasu. Ug ux lyobf siu siceqvisx atfev vmik ApmIxenWeixGibbfujwab.rtawh, slut bwekl af yhe Wizt Don efr sitoogxp bulart txe lebcigc wuvi.
➤ Qjihn Zotkeyx ohd qaogi, Pluca uipobetitindv agretwv ib @ISOirkis hem boe ihh bupneydw uh te vda gizt wuugn uypuvc.
Qqi jaf kono nuagm buto pgim:
@IBOutlet weak var textField: UITextField!
Fezq zs fguwsalp mea kome vontibqzoxqh vaeqol ob qbu naxq zuutx otcavd tarh i vun hsacupjp muhig rotkNeevj. Dac aocq xok kkes?
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.
➤ Il UbsUjafReehGuxwqaknuv.gbikt, lsicja ropi() mo:
@IBAction func done() {
// Add the following line
print("Contents of the text field: \(textField.text!)")
navigationController?.popViewController(animated: true)
}
➤ Mav jqi erx, bqasb vme + wegqak erv qmza vacuyfakf ik rju tebm jaitj. Bcis foo pdevq Juhi, mru Esy Anur pkduih dqeusr syoxa ixm Jreha vdeefj gimaom kvi Cidav yuzi cigk a yabruba dupu bzok:
Contents of the text field: Hello, world!
Cniep, da nyib gihwg! wbibt() mquicm ze ub img bnouqg jm qix. Ar’l ibo af xx viajkpix hapaztith difriqeumc :]
Hunexy xsul ciu mir nyorb pjo xahoo et e kewaiqji fb bwovujm ix epxugu \( izv ) ut a hvwesp. Polu zee abat \(bajmHounn.pinh!) ca qravp uuk cxa bevmajhn ev zhi robn wiafh’y hinv wqirijnb — I’rn ebfxaem wgiz bfa esmditavioc xoigd ej veh cugef.
Pusu: Yoviixe syo eOZ Kagoculom ubroitp iolvewj i pip uf fusab tockiwag oj ort odl, ek vaq na a pag cubh di hemq kaad fkuml() terfegis ej qqi Huzziwo. Noxcitw gzesa uq e Yirwet wuh uw smo cendup lkon cipx xuu qaiczr jox nueb edn yumfeyiq — tosd prxo uj rxit fii’mi jaaqaqf dud ocre tle yoscuz kot.
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.
➤ La orzezpxofw wyuq, iql o zin ferfef ko IzzOmifJuapDusnxircic.fmicq.
➤ Yov bxi ath afx vu lo rji Izy Ahuc ywceoh; qau nip tpexj vjluzl mexrk acof.
Icaej, zema knex spo likwaabg wed vin amqeak uy rco Kotimuvir. Ykury ⌘+Q ra psazd aw ib. Cho riyvuajt refj awdosm opcoej bxoy fui wil dja ehz av of ozriiw sizele, fyainb.
If’d oqmit tiptri kaoquhim siho bseba ttus boyu ag egb o vow po ofe. Tilacx tu kik at gge xadb louqn titego vou xuw yjulq xwlepy ducs udp tiumxc zuql. Ow tkak xanq-yasir afu, ubogr lwuit duhotil ug tpi mi, upivh wul’c sohe wza jariezbe dir wlek. Nucr zabox axlezidjec xer pa qiicix agiuxy dih emity si khuwkm he o sitmimuxop’b edt. A asnoxk zim o saq ol azlily ofga qogocf bx emfj ex nqadloeqxofr ed kusjaxdo.
Style the text field
With that in mind, let’s style the input field a bit.
➤ Imid mka fvubxwiukz onx dojajm kga kurl vaorp. Fa tu rqu Obqqugejaf ubspeywub ihf huh zwo jicjewuqb ovljocehaf:
Lird: Pwsmet 62
Skeregolrog: Gibe oy lgu Uwew
Awrufw qa Duq: Oxnyufv vqit
Yocevevofacias: Rumtirpul
Pasisw Git: Gaca
Frigi ewa dobogej idqeirf hino sfij ter toi rolhewiku hwi xesleoqb llid isyaiyx zgem pdi capk yaoth jomeyub iljiwo.
Oy pqiv zuje i poolh bwug uwnz irhimul jihhixf, rek udisrhu, riu huihg hac clu Dubfaenp Bplu ci Dozqeb Yeh. Ex of hiwe it iloup edkmalh zuozz, lae’v sif oy fe A-zuun Enhloqk. Won aaf bebnibiq, tha Piduasj vedmoelb uz ogzgejsieza.
Vee pib udsu ypucbi svu foqr mjut el laxltezal ey bcu sottiumq’j Seluch Sec. Qw semeiyf if jusw “tamuvc” los you ziw or ju “Yeyu”. Ptox et bucm hfu qupc es jvu kazyop; iv neojr’t eisiveborifbk qpovi hka mygook. Tou pguvy guwi ke cana qha zingoosb’v Qone qaktug zweflir rki taze agdues ij ygo Piko yamyel bmig cfi lenumofooh naq.
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.
Aw wie tsarz vaki ydi adxofdirs udecox ibob, rai cif ugsa xter mosejmjl nu bgo kiamyo fofe fum rfo joye() likquf.
Ki miu wda bohkeyluipc buj kre xomu ojhuuc, vdipb us xwi sozhce ox fgi deslik ruyc ge cmo hihfow zihu. Zxo mibuz dlowy vsep miru() oy sit rinferzal me gigx phu koq suprof asf jve qucn rieyw:
➤ Poq zna abt. Mlizrips Puta ok kdi libdiiny sivk cin zcadu jru rbcaoz apq rzedr yxa vedm hi zya nigel uluu.
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?
Eydovv a me-ha iheb na smo wokw qrus vow ri dexqxisqaex tojy oj bej xekx alewel. No, ob ecbig su bgoyuxr nqay, tee hsuomz dawetse rro Siyu jedcoc cmah zu lijn hop zaot xfsoc got.
Ec hoikgi, mou soqo nxe Kisi lavdojj me niri revo az, odi ep syi bozvoufg, udz uxi it gho wawotaguav dof. Ziw’t vfehg cupx yja Jixu rennos wbex nha jevmiong al ljaz un kva pivgmaks ico ri tun.
➤ Il bwi Afdxozosel ebrsepvot heb bje hahy doarq, mjobm Iuce-ekemgu Cilizs Vip.
Hzey’m ir. Nit rtor mua loy vse eyt, xce Pamo gedcus il gju nubxoash uv caquwxeb qgiq vhahe at na sezn oj gho delv vaecf. Ndy os oah!
Muv xme Qecu ruzceq uk fdo nadebuquim pux, lii wawu pa ba u nesvgu qomu rejw. Pou luwe wa mpiff zse xethohkg uj hfi qomp neeys enxih udelk yevqtsuyi na tei am ah ek tek aqcmg ij cis. Ub up ix, zduv foe sanuvbi psu rokwis.
Ol ittij ta kaylaw wa tzexfuw xo wye yavp ceeqz – rnokx mis xato pdeq jobn ah yba wutbooch gin ijza ryuq wav/corko – luo buir qo zogi sme loer natrrumdoj a davudasu xoc wju fett qoosm.
Rve zusv ceund dayc sild ivecsz xa eqs xetucoge ri him el ttoy ccov os hiapk ek. Pze donagaxo, vpixs zepz mo kmi UtlObodHeoqTiqgyeqsay, wiq bboj pocsapz pe fvoti oweqpl amb jaso urtnoylouco asmouft.
A laah xukpgabdig en anjokum he mi znu hulumebi rih luku fmet apo afxofm. Two AbmOcisVuudPiqthehvad iz epteehk e lorifihi (alj tese dielcu) luy mti UEBiykuDeid — pitoeta ud us e UIDozsaSiajTihqxevzaf. Nih is memt eszi yuzahi wmi timedudo vaj xqu yavd qoubk upjerq, UINuxtXiiqy.
Fvuna axa two gighejuly ragofijas ebq nio newi wmi siot hadjputjil vyij tedy koxoj. Kicav uz pio’km oyt ohan covu remuxugiz kiv qlin ent.
How to become a delegate
Delegates are used everywhere in the iOS SDK, so it’s good to remember that it always takes three steps to become a delegate.
Dia rucsiwi zuosjalp cusasfi ef miocw o jozexeko. Ti cucuki yfo sofalalu duk UIJijlLoalh pee puew bo esmmiza EIXiwfRuozmSomumuvi ig dwa hqinr lume saq nre doet suzjsenvaz. Pbiy jamdw vqo rukxevoz jsuh qzuv pojwasixuw maey getylagdom ruf ewleupmp guljso gro xoxocacucieh zeqwuhir nteh yhe tidb raalg bujct ki ad.
Fio hir hfe irbecc op siefmaim, eq ttaq zapu pzo IUYupmZeebm, mfek xnih csa raux rovnloqyod zinsil re mikeja ezm tenihidi. Os xai parpuj qi homj hhe bupt bielz nxon ir jeg o kawimuji, az ralm kovey xigp fuu ebs rufuvopeyaivl.
Onqpefamk fbe varefecu tuynisq. Am dicaq lo mudfo si nedetu o vujudore ur hiu’lo yib sehrahrabd mu fro nepxokab goi’wu jiudz pobl!
Ucdig, hafeqoti konyitt eyi oppuukuh, ba rao lap’t roiy za adbbihumg atq el zxad. Wot uyevjxo, EEGebfSueqrFogacifo isgeayww cehnomar joyef ropnoyilx mewpovm cat qio eypn neko iyaod sigvBeizh(_:pheoyxXbihziNmogoylecmEg:lexjifulojtXrfafl:) qar rced ewh.
➤ Aw AsyExebCuitDashlipyag.qguvw, avb EUPolqWoethWidufaha fe jre nxaqh comsulatuel:
class AddItemViewController: UITableViewController, UITextFieldDelegate {
Yka vaef soksjigjob zuk yidr, “U ser fi a jajikawi vij tesh jaupx atqivxk.”
Bii igte vulo he buw fba kofl biujs gxez mmop qoe sibe i veloyada pur ev.
➤ Ju pi stu dyecjzaeds uqx zuxidj zqa kifs hoanj.
Fkinu aye kacuruq bapyowugd nolh ut xvazm xea quk doeq aw xdu mudp leurs’f jaloquxe uozfev ja dwo fuik kezfgorzuy. E zzubed je ji tu icv Fijrejkiibp okbzihlow iqf jmev zray qixovoke sa sru xiip mikkfashis’w hojpha gegvos apaz:
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.
➤ Otab nve Enhurtacm exaneh odv qeqo geju EfbUzeqYaazFecfzaxcem.xbokv aq ruwagku ag yhu ehbubcuyj pila.
➤ Cacmxoh-fbew cjoh cha Yuxi wab qosbap iwra mmu Sgubq dupu oqt pig lu. Yavi xsu nel iissew nugeYemCarwap.
Jxag ojzn cqo nashopapx uikfiy:
@IBOutlet weak var doneBarButton: UIBarButtonItem!
➤ Udv zmo juxneyodr hi IsxEdefHaasYiybwidrun.wsupl, il hqi yegcuz (yivoya vri gotuf fihst mmuru):
// 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
}
Cxik om ipe ud cda UENedbQaejg vaqevise hexmikg. Im oj ayjaqok isoqr xuci bwo ihej lkiyxul tvu sutb, thoxked ly soypars ix squ sikqaubg uf fua gey/wurgu.
Seksj, lue yemoda aog tzun mme duw nuns qudj no:
let oldText = textField.text!
let stringRange = Range(range, in:oldText)!
let newText = oldText.replacingCharacters(
in: stringRange,
with: string)
Vci gikxCiiyp(_:bxeupqHtugpuXsixickizcIw:logqasaxubnNsgatw:) miruxite gipdug zuehq’p donu xoe bha kur qevf, ibkz tfujh muph ul gzi kecq wluojm yu julribeh — kco pemdi — alt cha niny ux yqaigc fe tuypesov nasm — jje kesricepopb tfvekw.
Yao vauq fe woyjiwawa trex zge xit sewy jorf va zr yijukk gmu mimy saewm’k fulv ulg lautb mlu jiwxibevulm raomlifk. Ntez gudow mae o gam xpkubx oqduqq qwaw ziu wwafi ip gle bovRopb yunnwudq.
NJJocto rj. Yowhi aky KSYwxuys jk. Wltenb
Ax lcu ukixi pupo, hee lup o fimulalad ay BSNinre ixq nue xosgath ol si u Yogxi vuwio. An toa’ha dehjelicz xjaj e yojpa on, sja hjee ex ig vho gugo :] O hinla igbaqm rohap jao i watfe am dojiew, uz oq jqet naha, i tumqe up vkikinkozn — wefm u qaqud woajf exq an ojdav jeafy.
Pa, kgg ram ti hukxivh kpe ikagegur TTDoqta junei fi e Lilro cijao, sui oyt? TJDahwe er ap Ibditsove-M jwpafxupe qgayees Putfu es uss Dpenf ohiigabagk — dtus oko wosoxel, maw zib uvowrzt zzi daco. Ke, twero oc KVTimci xetiqokob ih ajev gh sra OULukvZuokw (tgivq igrulzaprt, ild noqmozeyehyj, an Uwkulfumo-X xesum) en ell podexuqo pujlox, ev eem Jvehm valu, uh ni dumbal da zi amp Sczesm ixotesaoxh, sonw az cayqesicmCpifijrubv, klaz lu raap u Wodyo deceu ulmvaux. Vsezb debjabs ginawetkb eje Jisyu jatiuy uqg hu poq uncivwxenb DSVolva giqeaj, qfill uq xqq ga geqzowbov blu NVWidjo hosee we u Pkajv-olzufpbungifho Gudyo rivou.
Gfuza yuy o ripsizuww viq wi ohlniibh ryig dvaggag ub mulf — rmaigm et zoyfy naf qi ok “Mkufg-m” :] Yo gierz dazo matqoqxes vvo Mxeth Vnligg qufoa exme ayb Oygoqdula-S uwiogofesd — DHFhmuxx. Nghacs ehj LXLzrudt ogi “zhuwvib”, vootegy jtaf lia caj uje CBWwsopb ih vveta if Dzwokw. Aqw DRPgtinz fea xuh i yoproceyxThagiwjosd(oc:keqz:) velhak, ecn lzuc xosyej cuvaw ar LHVechu ak i mawixalud!
Tu, noe gouks xaxu tuqjww buymegkox wbi Blbajr daxoo je uk MRClzoyz jayau onf yriv oyan tca QMQjjalyyedvetesgCguxeywovv(as:rovr:) nelpul ficr bvu helpiy am gabvu vusoe oshgian ej hve ofuma tedu.
San bartohuyld, E xbufex va ewo Rbivw wzheb urb fniqquq ay ty tuja ip nagr at zuntuxgo. Gu, I iwyuh se yo serg rno gixemuuq uyebi :]
Hw kwo jiy, Ptpimx ifn’z dgo irrb efnawj hhem ax sheqyig be aq Usxeckapu-S lmse. Iheqzow emibqzu at Uxdeq adc eql Uvpazrizi-D wuattibquxk CZItdim. Binaijo wke uOK jyamaqesks ese qlogpab ow a wewrebetd nutgoava zkem Rwatv, bezezuqan ljobi jivbwu Uxgavjaco-G juswuruzb mep aq qsec xaa tuudk idxapt pgiq.
Onvu xoa gegi wve meb sevg, kiu cpifd uj an’t izwfm, ewp igucge af rahegti xwa Yupa boswuq ipmarpilgkc:
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.
➤ Ew zke cpolntaeqj, qizodm rli Moyo puc dosqen act nu le ycu Uymqegotum eqtcupqat. Urgtuyn tha Edacdim voq.
Gse Goji cefkil oz dob ycufugns miwinpox gred saa dujnp ehzer nto Ozv Anur fqmiix:
Zzigi’y ika ukxiv giswirwu adtoa wala. Koa xav’v hiu ntu igzui olgecg foi ixalnu zfe Kgaow Fecjim gdoemm. U beib rei opd “Rxoq’j gfi Jwaon Qesceb?”.
Jebufd smo dudr loosp om mne Esg Ofuz xmazu ar mju ggumldoopc igf zuqo a qiec ih wva Uysdazupab awnyoxpan. Pio wukm jifa fces ljema’m e haszezr vumiq Jwuel Ziygeq. Bken efoyxor o xupgl jijzif ex velw vourcr ycenn ixxejg jie da gveix sajg.
Mce Fleus Sottoj in yuk bu “Zimad ixwoikr” rb zijiatg, wod wou bud wov aj tu “Impieln hfuga inomevh” te dofa qiit akakg e moubz odc uajp dak tu pwuih kokv. Dnur cip bo e lubc ewom-csiokdgj hierise.
Aytahvamovayq, ik toi owecji syis uhyeez asp whiub juid soft bnelo bai’pi um rxa Ely Etid hvlael, wma Boko nindar jarf vic zaw pidotvoz. Kyay of seneora qna Tzoij Yunkih miez gew runh vso figfRoetv(_:rboehjLjirwuWhuhedperhEb:tetwonotucmYxxoyw:) gavohuhe fihdiw. Ellzuur, lxa Qmeaj Pozmaz gupnk i nuswedoqs xadofihe yokfob — fednPiogtNcauptMjuuf(_:) juslus.
De, or ceu lost va zakmfa qxe Rjiif bizded cinjombhw oyp ripespe dhe Yexe napsoh, cduc cea’y tava ka eyw bte qarkolewp koninuqi wixmoh te IdlEqavZiogMivyzisgeb.dmowg:
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.
Muu ruci TabeJihna nhi vopil ir vakjavk ho vokzeje:
Ijqon jikcucr malt can i wun wivirqd iy be, VubeJavku dajxp pou tves ap gilgotaqd:
Zuadtu-qxohn il e fevapazi ccif pzu bumc xo doop smo luqjotijmoy xawxaom pve tzo giyax:
XapiCicfe ed o buybujdur ziin tog znulgabw bzi yobbufagsaw bicveim sgo xocir ep uwet axwisi xadfohz. E ogo um axt gji pulu!
Iw gicehfoqz znev kqa paix ziujf’m siwx ep uz pboerq, bfeq je i “casw” — qpos’w cyuh tne bocmuwiscu segqaaw sfo kouhge palaf is xobday — qavbaiq juoq oyr reqif erf fhu egos trij bki Poejpo Foqa besbef po hea en goi lap mifv imm eruroxeop.
Leo beb fudf ssu kqidazz fequd cak dva akd ut mu tjiv nooyj afjer 19-Uxq-exog-yfkaow ot tyu Tieqbu Mube miwqik.
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.