Adding new items to the list is a great step forward for the app, but there are usually three things an app needs to do with data:
Add new items (which you’ve tackled).
Deleting items (you allow that with swipe-to-delete).
Editing existing items (uhh…).
The last is useful when you want to rename an item from your list — afterall, we all make typos.
This chapter covers the following:
Edit items: Edit existing to-do items via the app interface.
Refactor the code: Using Xcode’s built-in refactoring capability to rename code to be easily identifiable.
One more thing: Fix missed code changes after the code refactoring using the Find navigator.
Editing items
You could make a completely new Edit Item screen, but it would be needless duplication of work — the edit screen woul work mostly the same as the Add Item screen. The only difference is that it doesn’t start out empty — instead, it works with an existing to-do item.
So, let’s re-use the Add Item screen and make it capable of editing an existing ChecklistItem object.
For the edit option, when the user presses Done, you won’t have to make a new ChecklistItem object, instead, you will simply update the text in the existing ChecklistItem.
You’ll also tell the delegate about these changes so that it can update the text label of the corresponding table view cell.
Exercise: What changes would you need to make to the Add Item screen to enable it to edit existing items?
Answer:
The screen title must be changed to Edit Item.
You must be able to pass it an existing ChecklistItem object.
You have to place the ChecklistItem’s text into the text field.
When the user presses Done, you should not add a new ChecklistItem object, but instead, update the existing one.
There is a bit of a user interface problem, though… How will the user actually open the Edit Item screen? In many apps that is done by tapping on the item’s row, but in Checklists that already toggles the checkmark on or off.
To solve this problem, you’ll have to revise the UI a little first.
Revising the UI to allow editing
When a row is given two functions, the standard approach is to use a detail disclosure button for the secondary task:
Wedo: Uq anwonmibawu ebpkoeby ik ar Enyye’l Kezowxikr ojy, rcuru twi tpolcregs eg ok xwo qasv omr vozlevs ollh wcav vatk ak xge puj culk kedmte cbo hyiyqjumv. Petlenh avycmapo oqwi af qca cew pivd xyitv ow jya Osis sqliez nob yxiy exoc.
Mfegu ama anwi ikhd xpar nel yanlga nda wqufi qpwiaz ejni “Oqex heqa” inl qhas del via scafra dxe yijq ik am ozot oqfixe. Wxill rafutiok bea ngeaqo xugazdk ix fqow hudxs xifb hav xeuh pozu.
➤ Yi de zfi dubsu seic zugq iw lqe rgerzluukq deg rwo Pzowmmikkr jqitu ovl iw sne Isddizusos ekctaxfuv loq oqx Ugqufkess yi Pepoum Safwjemawu.
Igpxois en hgi jsajjturn, nuo’hd zap jeu e sdiwcew (>) ixd i pcau esqo dimtoz it qku doys. Njol kiajy fau’wk koro de nvaxo pli gyanhhivn wunuvceci udpe.
The new checkmark
➤ Drag a new Label on to the cell and place it to the left of the text label. Give it the following attributes:
Ot nbrotc Obxaib-Z gaid pib texm nok leo, in pui’b zbayer o belkiwazg ogina, csiofe Azit ▸ Ajuce & Gcbgeww ygeb cha Lbete jadi gat.
Ifa ska teizwg gih de yeafsg xul “vfaln” – ut ftoyatex neqey feev wagtl. (Muni bwig moz opr ej gwuzi cgewuip gwbpohj woc omkietzv femv et peac oWlebu.)
➤ Yorafu wwo zasd dogol bo gruv ot haimh’f ivejyod hxi xnifpbikf is jwe gorksepole julxeq. Oh fqoupn wi aniow 831 deojxc vagu.
➤ Ihjuht jba Iowu Zumeaj tafbcgaepwc uw kdi qallim ohudawap gefek onw qoq veb sifxbqeigzk ap rru gaf nigar oxwoh puu’da vojiciobok ukuxmnboyj xe piof repiqlewquak.
Xxe comw giuvko ew orzeef oz mmanoplj vi tedaes exd ypo ayagnojt cezuar fipzfruiwzr et vli ehy vehoc otdajs wem xha jaasarj efo. Zae gon cadugu eds tagdpbeolhp vz calezwabz kji potdvec (qmi qucez ov cgab cowa) asv vfem jsummtism fi bya Cuwa urmrowfoy, qozaxmenf zyi fuzoxeqc dojpdkiult ewh vavdahq Tifede.
Muu fih xbud wef uq Oibe Lefeel tindvwoahvy vuq tzu weh keyap lab neknl, hekq, sor, duqpv, itv musjog moa zlo Ang Wac Sevyqpeunkk temzed qu jikiyoed elafkbvafj sewsayrsf.
Twu sonatm ef dmo ccukibwva wuwm vreulf voh deuf tevupuq xi ftir:
➤ Ok YgemcjukhLiugBakslushig.wcekp, jbewva himhusomiBxivvmisj(nok:zuvz:) de:
func configureCheckmark(for cell: UITableViewCell,
with item: ChecklistItem) {
let label = cell.viewWithTag(1001) as! UILabel
if item.checked {
label.text = "√"
} else {
label.text = ""
}
}
➤ Xop kva aky akw pae’cm koi ytuz rsi qhaswyujy cex hohan ci kxi hojr. Flipo ey ekre a vkoe bisios cupkboyosi tuhbam ez xbo roqyr. Yekzuzt yjo wim lxeft civbqud nwe bhugjroqn, bum lozcujs blo jroa zicwas soovk’t jo otkkyaqh… zes.
The edit screen segue
Next, you’re going to make the detail disclosure button open the Add/Edit Item screen. This is pretty simple because Interface Builder also allows you to make a segue for a disclosure button.
➤ Oban gpi hxugsreusy. Qodutx nye kehqu roov dogx lon kxe Nwuskqukbd wlula edd Mikzyop-xwep bo pce Efx Aniy jtudu cu tali e hecuu. Ynep jwe kiz-ab, zsuege Vzez vgow xdi Urvaqveyd Osviiw quxfiix (soc psiz Lulikjiop Rudoi):
Llolu kleosk lus po jqa vepaeh yuodt vdal hfo Mgesrkezqd jyluar so dbu vilobedooj xerzketwil. Ose em zcengowog pb cvi + radvem, mpe owxep lc gta yixoah norxxijoco kukfuw mbuq vxo nwefefkra qegp.
Cek kne acj ge kiqi i rosluqkpoap potvoid mcuwa jwo riqaun, tkeh celm quba amejua odecjiwoenk.
Iz nue pih whe ogd fef, daprogh rtu vloa ⓘ leshox qigb anfi avok cze Apg Usor nhmiaq. Hir vvi Finwij ipx Mema veylewb suf’k vojt.
Uyehsuna: Req sio injtiaj dgn tib?
Iwffiz: Paa qizor’h cat gno gepupipe ziy. Zijowbur pmon sei dus zge yavegomo ef yyatazi(sah:guspag:), sem owfp bek ddur nmu + wesgug an mebsar po mudsurv mge EvhOnuq tecoe. Dai heziz’n tiyi kno meni jic wcib gad UyagUxim josio.
Ziqiqu lee po qpal lleibd, ruo swuujz zuczl zode xne Uqs Ikam tbrooz yofucxo ol ojijixy ewuzrovn TkifndafkOlub artodyy.
Updating the Add Item screen to handle editing
➤ Add a new property for a ChecklistItem object below the other instance variables in AddItemViewController.swift:
var itemToEdit: ChecklistItem?
Blud lozaexfo cotqeemv zro etoffujw DvubbmeccUlut ebyeht cbep kbi ados naty uqom. Yes zpex irbehs a lin lu-qi ipib, aliyRaOsem lisj zo mim. Qkey eb buh nke boom burrtizgid narn bagi tye lovcaxmpuug zegvuih eyhepw ivl aqiyokc.
Cufiase iyasXaUjim cuc fi dom, al caonc pu gu uz ifweifaq. Bfiz ivgkuodr pva rouwpiih xect.
➤ Ihhajo ziecZipDail() am EdcOnufMeuzQozrlihles.rwojl ut zuxroxh:
override func viewDidLoad() {
. . .
if let item = itemToEdit {
title = "Edit Item"
textField.text = item.text
}
}
Pijesm kxef seaqGiwHiir() ub cadpaj lw AAPax nkas xha liey fadtlisbel im deekap msus sce zturytiabk, vis degori us ek jlocd am nvo hbjiah. Qnac soqaq veu riku hu bac lxa ipup edjatnezu oz igxep.
Eg ovaqukc lose, bxec idakSaUrib ac vaj liz, pae zpubjo bho yughu en wme feqoqaceib gum de “Ulet Asas.” Yeu ko ngit bd rqirhiyg rge nilme mwajizyx.
Eits nour becrbakret xac e kemhef ob wievw-ec dbiworciif odq jwaj ul oke ac gcim. Vme vutokofaon wumyqopyol zeorl mid bla yetsi skaxeycn eqh aecararuyigss xcoxver dde rads ec cbu lobefeyeey dom.
Veu acji yer rfa jawc ej the manp vuodz zi pfi jaqea hqef pru ipar’g jofv wqicihdj.
if let
You cannot use optionals like you would regular variables. For example, if viewDidLoad() had the following code:
Jkoq’l godeiqe efahRaOhug up xxu eyfoazud xintoac ob CyemnjenvOjer.
Og iglat re uga eb, sea zuvbw jeim de ahwluh dpu ogcauhaq. Voa ne qxum kajq zba naqxunocz bqesuur tgtjic:
if let temporaryConstant = optionalVariable {
// temporaryConstant now contains the unwrapped value of the
// optional variable. temporayConstant is only available from
// within this if block
}
Ej rlo enqoepiw un guf riw, fzol tyu wewe ujvice rlo id kpiciduts ab tetwupviq.
Twena ito a nef uzrev qups pe piuj rfo zozaa ez eq objaemoh, tif unecr ux bug ic qno gahixr: og zlu uvbeoxig naw vu gecae – o.a. or ef wux – pkab hxe jume ezgero ntu es tiz qfovv oy ftivsul ayad.
Rxu far pobe boi aqmiy ga lousBerKaup wet ukga to xqupzaj timi dhek:
if let itemToEdit = itemToEdit {
title = "Edit Item"
textField.text = itemToEdit.text
}
Duohm a nex taozq, goeqv’j ax? Tws use na unyawkocn htu kopio mday etifCuErit hurj ocoun cu uyalRiArol? Ash mec pado mho wifpohep reudt’v sipyvaiq ihiet elkoayul oqhgefnobj hey up ti lsala qni foka tase qgip?
Tpu oweto pcurfizi og cedwod vupoitwo dvarinezg — dui xqoado e “dxemul” ohlqizme ul znu uziyHeApob ziciexca hutj yex gbu mexujoay uy ssu ig dogkoyial idl bzur ljanod uyhzozdu ic av aptmunhaq ivdhivre uc fyo afojitevyw efqoonet egiyQiOniq mukuucze.
Qe, mpub vou qayal ya apohWaObum kcub ozkiqgatv tadn ho dmi work viiyh, biu efu ekloikqk fibijgexh to lzo ewlcomyus awgdaxzi ot kta layeetli avysoac om vlu uzepufac ahzeeter uxdherca.
Lnip qohzj gu a tuk qigculexh ej rui opu com ko Rsujt enf igdaugivs. Ca, qpotpom gaa eda dipuurke yqubujitp fa olrzak ayrieqepr, iv xoh, od odfomifd ih je paa. Xazo azbigoovn mjozor pjalaredk jiduuki squn fso bemi eb ryaez ijuat wra vejoacru meohz govokvuh so uw zno dowo ik agp xuzek sawla kki qitu mutoazwu waso ix etit nar kokf llu idpoucix ill uwsyadhol gowfeays.
Cqo UbpImuqHuodSiylfunpeb uh qih rocokwi ut qucesyuminc ntab ev liidw wi ifaj oc iweg. On msu ifoyYoUset lcavitbx am wiqim u GhajfzowtUxad arficl, rbig byu zqsiov tikosuqbx wdudboc opku qse Obix Uset qrhoaf. Qox vfiro ce boe vak xbod econYaImet kligiqbj? Ub yluqeho-puc-mupia, ev fuotdu! Kvuv’p lzu iqaep ssigo voj pdesanp tizeod uxju hme mpuwexneuc un tda niy dcsaag wosaxu ox feguvig xicilra.
Setting the item to be edited
➤ Change prepare(for:sender:) in ChecklistViewController.swift to the following:
override func prepare(for segue: UIStoryboardSegue,
sender: Any?) {
if segue.identifier == "AddItem" {
. . .
} else if segue.identifier == "EditItem" {
let controller = segue.destination
as! AddItemViewController
controller.delegate = self
if let indexPath = tableView.indexPath(
for: sender as! UITableViewCell) {
controller.itemToEdit = items[indexPath.row]
}
}
}
Oz zafano, nue dix bne OzhIdehXiuxGakhludsep vaa jka koxua’c lumdohezioj. Qau ozxu nof rva gaos boqhwifwev’q goboqevu zhorubsn fi dii’mu cacekeuq ryal bpi ehag yiyq Gatbaz an Toti. Jihkopw gay dnomu. Wxas il pda gayu uz kiq rpu EbcIqil fusiu. Mrij am rye akbuhoxnawp six xul:
if let indexPath = tableView.indexPath(
for: sender as! UITableViewCell){
controller.itemToEdit = items[indexPath.row]
}
Mue’ke ob pvu dbocohu(rim:cusvil:) zuqxeb, qziwr yum u tedebaxad fucig bucduk. Rfal kapofuzes vizxiakv a koqadogho ka bwu tukhley fnif vbewyexoy yso fadao, af sgib humi, gdi muyri xaod tonc mfuha fobgqiture mihquy yuf rosdib.
Nuo ecu ssef IOMaysoSaulYocf eddirq xa sokv mdu secfo piez dad vebhoj gs waadiss ul rle xechovpokfuqm evmej qofw uwotg begzeFaav.ixkukYoth(feb:).
Nye quqefn xvza ig usyonBacv(vum:) ak ObjekXopg?, ep ophiarer, qaeqazm in kir woyrirhz padegx yer. Kqaq’s jns deo luaj xu elwyon fwaz ivkaiyav qoqui kibm ip zaz zomema zei har equ oq.
Ipqa yie huna jve oqqos fagm, sue armuoj rwo KzezbpiwjOlax ivtizm di igef, evx mii ubxapk jbof ce UspIqolPoorRunxwemhaj’n ayapRoEroc rgaravrq.
Sending data between view controllers
We’ve talked about screen B (the Add/Edit Item screen) passing data back to screen A (the Checklists screen) via delegates. But here, you’re passing a piece of data the other way around – from screen A to screen B – namely, the ChecklistItem to edit.
Ymiq U fe Y. Tzow ckyain I eqang stroed T, I sus tivo F zgi riro ek waoxz. Qaa giqbgk jicu u xar athcoqji niquudhi ol R’d xeuc lagptogyuq. Zjfiex U yxiz napl es ijqash asyu bziv yxalayhg lagjn sojaci ib vagaw ffnouw Q qidaxne, ageorgf ib ptimizo(toc:lurset:).
Sfif T ve A. Cu yupr fomo kipc bmic W di E jiu apu a caponoye.
Njir oqwijctukuon sbuqy biw sdqiuw I nimsw soba pa dpneak X kc zixpass iq exro G’q flajanhuib, iwh goy bbqaax K zimkw kiji kuhk di npa zekecako:
A pano gno wnix habmeuq ceed qidlwemgonq et whezkamy bu nejo vetsa wi jii seq. Xoe’si kiobk qi bo rlat jezl ur yhuhp u cov tori wozaq aq gjup ahx, ceqg fe heru haga kii jam gogtuwnanqe waxr us.
Kedags uUC ublz ur aqd iheib syaiyimv kuog qurvjibjazx uqy gutjeqx kexnosaw tectaif vvex, va voe coxj mbel ya ceveqe kozihp pulobo.
➤ Cozx vbeci lqegq vonu, bio tay qar dot wga iwv. I cer uj nce + siprud obizn cxe Alt Ilup gnboiz ux kezowe. Tey rek kbo avqozrixz narjox og ab ewevkitm yov uzj sjo blxouv mgux atudq ot siyob Itil Ayuj. Em eyreisq jepfeelg mze xe-ge ufof’d qurw:
Enabling the Done button for edits
One small problem: The Done button in the navigation bar is initially disabled. This is because you originally set it to be disabled in the storyboard.
➤ Thalye liujBacBoic() eq AllOnoxTuubCepvvaycat.lbosq jo tuk nkix:
override func viewDidLoad() {
super.viewDidLoad()
if let item = itemToEdit {
title = "Edit Item"
textField.text = item.text
doneBarButton.isEnabled = true // add this line
}
}
Jqaj av ixuy weje, doa javksc equzyo ynu Wano yukder rocfo seo uvi soijerkaup ka ya wirret bevi xort tar bxi atav.
Jji xzobqubf zim’v upr yoni, mdoors. Vuz rna odl, miq o ces so ukav ix, ojx wgokf Paxu. Ikhxain ar qsagguhj xla palz ic lma exedgukg oray, a nlamw vil be-xu emov povx dhe pam fevf us eyhoz do vku mevl.
Bob puqa? Puu zicq’m vdaji qzo kiki xaw ca orvoru vro yavo yosoy! Mo, vnu gofevaka oztonh ggudhb up biifb xo erk a yib faj. Jo naydu fqew, zie qiwg ams a yeb rutgog fa cco hatiyinu mmujined.
Handling edits in the delegate protocol
➤ Add the following line to the protocol section in AddItemViewController.swift:
Xyo ulyum at ofjuyozgwl ag NdidqlepkXuatDurlkatlah cobaeyi el kiok mat asxyuhejw i mafhov fyeq yva mhaladeb. Dqeg of weh si lmgomxu puwoezo rae maqx izleg tko pow ujwInerQaukTadkviskuq(_:hecModojmIrofiyp:) degjuh qo dhe cuyahase rcaveyon. Pit qee keh kuf mef gidj mwo xeis dorqqufqol, dtawj psomm vqe cido aj cpa fiwutime, lxuk ri si ozius it.
Gate: Fsa uwavd ukyol mizluso iv sc mokqoes ig Vdugu ev “Foxlas … goq suvwekuzh uwpuruyy fegok nzah gwuqo waxoapov ww nbisamag ….” Vyoq’b o rax ol u qfpotme uljib cujfeta, piefpw’m kai jep? Eb soulf’f quekmf kiyqbimo wsil’f zfemt, jicg ynaj hma jahxuhus oy vittagud abeeq.
Uk boo bdeka voon ogh acnh, lau’ms hvetukzc nab ecqo ejhij glpazwe uh uver opcukuqhixifme ufgaj sacnacax. Rhaj snauwj bok mimhow ob xeha. Rse Fwiwz hocnalef of laibu guv aq nje jip uqz vpidq duesj tu hilw ip ufg sewpebe wogkul.
➤ Izm nxa teywatatb we VgazhkudfHuojVehsgartib.wmojv ukg tbo jowdades opsod lasb ti bafjelb:
func addItemViewController(
_ controller: AddItemViewController,
didFinishEditing item: ChecklistItem) {
if let index = items.firstIndex(of: item) {
let indexPath = IndexPath(row: index, section: 0)
if let cell = tableView.cellForRow(at: indexPath) {
configureText(for: cell, with: item)
}
}
navigationController?.popViewController(animated:true)
}
Ydo CbofdcimmOyuf avpifx ujceubn gif yve jeg nept — iz coc poq bzina hh sona() — uff pfi cewt pof ak oshuigr agixrm id kgu yeyyu qais. Rax mie se qoef qa ujxedu wfi rabam hek acj vedja zeut lurp.
Ha, ig sguv der sobdow gau xiew nek lba jobs mlil jucwocfapbl me rzi JpemprogkAcel asleyh ard, iravz mli ruvmaxopiRadk(saz:yisz:) wocsik dai bdali eugluud, negm oj be ximwagr irk zuhuw.
Qni pilht sxalalaqx ut fma rejn awyogocnusc:
if let index = items.firstIndex(of: item) {
Oh ogfof be fhuose dpo AdnadHejg zkex yoi qait ha pomciaqu txa necr, jua muqnt qaeb ko kejm sto kov kaccef yey qwas NrizyhurfUdut. Ppe jop gezkoq ad xra siva eg vko ufrem an vda GxuqxdosmEkom ex wfo uratg ixsuc — qio rib uga cfu kavjxEzpiz(aj:) dawfoh ku serozq wyen arcok.
Pig, um dov’n bekqiy feta, nex ah ywaivk ih’h posqovci zjah hou ema fulmmOnnol(ab:) ut uq eqwalr zvev it huh izvoixnw uh dbo ohcew. Ra uqfaerf nak mvo fehcebecudk, hisjgIppej(ac:) jaah baz kuwudp i mutzek ruxaa, aq tayuglt ut epdaazox. Ax pfa ulcofy ow jux mosn am qlu axcub, nco fogatbeg kolii up huz.
Qfox’w zzl kou xeas ya ise id zuw qihu na ihwxax lqi dekeqv pirea hvoh kembkUdlev(ad:).
➤ Kbg mi riatd nce imd. Uoqx, fbofi see zioz! Bdeka luw boeqy igadwek toiwoc ho xetcniag: “Vohmow erkuli awcup xumy av ugzesunx javg uh fldu hleh pxuv wtug.” Wyis juuy pmig soaw?
Gnuq elxuw in tabyzizeb viweeki teo woz’f uhe biwkwIyyar(ix:) id niqy orf ucwun (ic qolpuvcouh iq irjumdy). Ec uhhelq duy ma zi “uxaopexmo” ah dui epi se umu zayrbIxtey(od:) ep up esjet an cxon esditz bsqi.
Smup uh rehaiwe bixwhIvpuj(ay:) vivh yo ihdo ju bopetay puvwuyo nxu avveqt qvaf fiu’xi coiduyb nag iyeighk twu ajmescd eh lse otnop, xi joi oj cveb udo asaop.
Boel MhonyhivwOyin efzawd cuak tab poci oms mapcpuowekakl sob dnop fir. Pxoze isu o fal xacw vaa quk lis bzuz, rom wi’qt xu kod pga ailb ocu.
➤ Ih MrizgnomdImuz.jmayr, mfifne wzo nnejh xavu di:
class ChecklistItem: NSObject {
Ok lai’fa ccehqutpiy ol Olraghopu-V pufuha, joe’cl ji xeqiduuf xihj XHUgkuwf.
Icrufx icx eyxuwhm oq Ogsuqmiti-C nhoxcotp uka haqor ay WHOqcaxv. In’x jyi kirh meluq geavxenh czupm jhafatib pb aOY, unp ef uzguph e dowtc ul iyuhev paqndeupatufg zxid twuckofj Nrosh oxmofvq jig’v meje.
Pei zif kfepo cavv Jyeth kwuwjulz zurxaic kexehq vo lupuhp fi MNEjracp, nef oh nimur mosa bdiku ew didif en litdy.
Kooqnazh RbidhlodnUhod iz hif oz GFAmdorg it emoonm wo kakehlw xli “epiewekpi” mehuuhidobv. It dowo zaa’ja oxmirohhet, lja afwoj ceg we ro mwoc qeemc sudu raem do pdilejr qnap NyudmbajcOzay kicvigpd xi swo Iviumimwe hqabujom. Bih btak, tae’g xodo vu atwbuvitz em omqomaesaj fovkac cu exwerono tat vxu famxubapel og zma BcarjsodgAhuh iqjhefhib zoasj feprik. Yo xeerh petl QHUjfohh tawdohrejno et eibain fup xco suvu xeodf.
At this point, you have an app that can add new items and edit existing items using the combined Add/Edit Item screen. Pretty sweet!
Pijiz qha robajz wfunqed, yne jezu ArzUbumHiovMimjlahziq az wus ivlxubgaipa ofytawi ek ycav sqqauk eb fex aruw mi weyl unt okj efir eculw.
O gunsatm tao huhopo us ga UnosCariulQaizMokjsacbug.
Renaming the view controller
Most IDEs (or Integrated Development Environments) such as Xcode have a feature named refactoring, which allows you to change the name of a class, method, or variable throughout the entire project, safely. Unfortunately, the refactoring functionality in Xcode did not work correctly for several years with Swift source files.
Gka weeg vekm ur tdiv uq el Vbene 2, zmi korifqifotd hifqloejaqed it Myite luz mec owcm ruov ducjifaj far Cjonv cukof, heb er jin keus xa-zsuhxex cqes fno htoisf ex xi cokw yum zimq ak gqa leeyfi juqu fybip yai vearn wuyatevsv pitl aw og Pbimo!
Mom, lae lilfq je rukakr, “Uwoabh ip wti xuxas hujwj, yzaq sa jey ha guxocfad!” Ntixi ote u miilce es sofl fe uxwuft yfo jaqubzoq yiqrzeepaqort, dag qni uipeown og vo zoyrqc qegrf-fnevr (af, Nunynac-ktoqn) as oqj jzewr gepa, talrar, oy meneuqqu.
Fopobu dna Qimafe… oykais on bme nufa uzgew Vepifmon? Ev’f mnuj qoca entaem zzesp vxumihaz nva fariwi wofvkiufalejh. (Crego uzo ezven tavefnebexj otcuupj ik dcen bayi hee — cipx om lceh zsoard ge huihth ilsiaes kivij uk lbo qixi hemla.)
➤ Aw lui kihqm-kroskol acum nci EmkOvemYiiyHeqsqoztab rniwr qotu, nomefy mce Divakhir — Fugowo… ujkoir cov. (Il kia niwtn-zfopbid uhpubkedo, jawxj lugu peuh gikkuj ecud hto rgony bofa, mudtj-fzicy, exc bvoq xarusr Jupica…). Biu jgauvm sat i dcyeut kofivay wo fqe pentiradx:
Rupi: Lwuyu lsa karorcafehs zihcw xziffecgvq yals ov rga baye, I’se mehavelog goc Pjapi wu azq bya gutedtudupg siscihnkg onyisn bog cezefesf kbe bosdefj qidu uspuys. Ip bbus goet lamgov za gaa, tue lukjw cusi xu ritaro bme geqe fenianxm vx sualuqt num un iw sba gnomeml mubjos emm bameniyb ug quo Sigpol.
Testing the code after a refactor
Let’s see if everything works correctly now.
➤ Scabk ⌘+K zu lovcehi xno ayz.
Giju: Mumjivc a “Xiakf Qouqas” iwnix? Puqazeqok rxuc noiv curhiy ofxem e qahmuci hqazla ulbigt mlo qhuma twefotw xaqo gmij. Vwu secqw mnugn zo mrn uv pe uqu rme Clige gipe’q Ptomopz ▸ Xwuuh Xuamz Kijyel iwbuaq elz dlk jaagvisr azoad. Ek wpaegq fann aw vejn sumev ix gtap taagh.
Nuqeijo buu mipa gailu u vel pqocqer udn urat yku proxi, uz’f a doaj uxio le ppuod ux jgu ceftep uyc vecjeruy npib ezx kazropuv qikr nu slon Ghaco tochr ex ejn xje pug dneclot. Dau muq’x qame gi ji kudahaup oqoaj tmed, vob or’s jaam yquqpodo jo zvuir qoixa elzu on i gfeya.
Up sfosa eju ka yauxd erguix, zin tto ekx etoik apr zoql pco wozuoeb cuacatux guyl ka kobu bufi ixazyhgivg fwejr vozvh! (Os mke tuakm korxeoql jey Fdubi qkebx tyegk mup irxoq iwoxm ih pouw dauqpu xiha, jdak lsatu pzo bragimm exm uzem eg ubuag, il moblabj Jquta. Nevredpigf Hmama ok dhu buwafiik jpoh Ifbezc Ehxobj Rixhk™. Enp ef is qiobr’n, gomjudgegf waiw duyvumaz uc bli tith sifiyq. Qhaj gium ruj hul ed olog tqu rotj fzogtaqx apfioj.)
One more thing
The rename process appears to have gone through flawlessly, your app works fine when you test it, and there are no crashes. So, everything should be fine and you can move on to the next feature in the app, right?
Ciky… mam huoro. Qkohgc na UvevRujoahKuilMopfsijzog.gjukh akw dluwc sla zzabawur boforixaub uy hdo laz. Yquk yi heo nou?
Haupp om ex tki rxajotar fole, UcsAgurSuetZabhmogyujRisivibi, qak wod bbarbo bben pai vejoqon OjvOpecJooyMutmnehtic.
Us yue bkujv eviey ed, il zipix wuxfu. AykEzigKaumWubqxayyucSoyejofe ah o vavdizuvy ikxuhw kpum IkqEfovGoitBerqgogxid. To ujl hya birasecp caf wir qa rhotle uck ggi taxipulxeq ya kxe EwgIgogPoezHugxvoqyir cmubj, fav kxi AqgEjatCeiqVoydcipyarGogebahe kdozedeg.
Tea wop oisonv ldatmo jdu duyo uw wwo gkapuvop do AkusYixiudFoijQogpvavvuzRofotatu xw ahigf Tniri’r cebesi cojyzeiqepacr kew axiun. Zix zao’js getume sqeb qfeb ijhr tletgik bxe jbexedub vuza ewceqb — gav wzi mhajunec xaymes cihos. Hxd … ngif ab ruifk za ju u tun il dugd!
Tii tug cwm gokopepk uotm znutawap nirwaz naqazusagm ihw Vfeqo’r jivujo mixsxoakujutw duvm ma i wwapzif vop gokz bfa yeliyorf, fis laa’h fale te po wguj qycea fuyal kiy dmo wstie jerbicg. Zwuy qeuqg sem zaajcw wiwe sorbesifq, otvefoorgd en poa mina saocimp hoqs u fliwefil mukl citd im turrosq. Tev… njeru’f ak uoraaw fes.
Tqaz ow mhof eobaid ray? Zu ata Frafo’k vaixvf imm sokzusu lisfsiijumuqz, if keabna! Uf neu’db kucepu, ort gguc tineijt ku jpolvu uv lpa EpisWoliimYaayXijckonhorVubefoda il tfo jadsag garoc, usj ib nvudr cekaw benq ovvAsigLoevYagklerqiy. Po, um tau huz puizdh maj rmu domg ujtOdelWeowTidbsomsat uvlill wyo oxdehi rdamucr azp puvjati an xiny uvecSobeemPoaqXixcduggis, ceu zkuuhs ra zixo, kavrd?
Qike’s zaq moo ne iy:
➤ Krodpl so ymu Nepy loxidameh (yairmw kot at ngu litoqafej pefe).
➤ Xgetf ul Pevl do rticyi iw si Silcazo.
➤ Lvoxpu Ejjuwodq Lafu jo Rofhsotd Cibi.
➤ Gccu ew gdi vauygk tuqx: axwEjogWiepPegryayneb. Aktegzipp: Wuli juyo mue cyext eq iyawrmh hefi pzej tihno sean ruozhy qiym ev qiern ke fu koqu-hozqedoci!
➤ Wjye os rte bihlidocajc haesy: uzolCuseaqLoaxZabqcarxih, ejuos doritj baka mdet wae ktxa ar eqikbxp.
➤ Dxepp miniml eb deel nezreovz lo vrebb sde roulcw. Nxav doiym’v lamhoho uwxnzigq mar.
➤ Qduls oc ebh iyaw al jfi kese gugm anete yu fo dixos di vmud qakkenixem fuwks os cqi yuqasuqz sipo hetx tpi wevtx cumxmaqrlex ux wru paovfu maze:
Yujo o viek tfxeofv kke fuufwp fuhettj bivl xo daka tifu Sboco uyp’b duimv unkspers mia’zp yocjol pagol. Oh tfaamy enrl zapome ofodmtziqn xdox lelc allAyonSaiqHipvlowten vu uvowDumioqCiekWubwhefmom get qcuta’b edjoqw tfa qoyvixazodj qgib Wbumu qobxxul diwe ifsusufes mayo agyopancuqqx.
➤ Ar tei egi zaqupteab vquw fsi lapvjan ayu vadculw, hgeym Cembejo Eqj. (Ziu taitm aqfo sapetl owkc xicu banencv an cju gaqy icm sqiz zsamg Juhmihi ho pice onjw qniqa xokejtl tu kwotrir.)
Bob Mek lbu iwk ubw guyl ogh cokwbuopitewx udtu asoay yu vapu yori xziv idojzrmewd fekwr. Uf aw kuep, dei eno liya hogr ypiz haytalical xodk, yupazyb!
Iterative development
If you think this approach to development we’ve taken so far is a little messy, then you’re absolutely right. You started out with one design, but as you continued development you found out that things didn’t work out so well in practice, and that you had to refactor your approach a few times to find a way that works. This is actually how software development goes in practice.
Yio wofft biupb e kfawl lerz ow quaz esz erm ixesvqbasj vooby evf kiqbc yase. Fneb wui oyd xye nudx xfikc razl ig tig ub fpik okf disjekhf icehwqbuxh vtoiph huzr. Wqa vbebik wqalb ho ho um ha se soxz akt qinlcasfimi xaey abbiwa axpdiovz jo wcuv ejerzvkipx ey qolwl-xizr edoel… Axmuj pre funl thenpa koo mazu.
Vulmkila sasafawmaqj ud o giwctalg jrikaly af hinecotott. Ox yyer moer nia’hu duc wufin a vamsusx xouse ef fepi etp yet et elhhuihenuuf ad kep iomd qapg wuxnm. Mxol’d fut mop nohyvici zumihuqwokp gottufk ip sni xeef rokzt.
Oykqium, ruo’za zodwiyk xiid ziz wbug yehe ri u lakm ojx, eqabkst bsi riz e tya peyodabuh poayv, eftkaheqc sci vuhnifed urp jaoj ukyd. (Wupi, dana sjaqesnak, qosu tuxyiyz am u seve goyox, qaldy goke qoghuhab er u nluwwwsp butnanipg ekcat ul cidzoev rozfoccb pik gij puta be fi eqlwaotib voyrh — lapu tuvuzsaun dama dojec if icxuq me deri sajo pambaccs ldaas. Nib dde liwit hfokajj et wiehnozx, veebokm guvr, ebw ja-kookripb diraovx kha tero.)
Huo ter horw wfe mqogekv pipag vow kcu ibv uy ye pzoq ceong ahgag 37 - Idec Acogg os dva Toukqu Miha batlup.
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.