Your Tag Locations screen is mostly feature complete — except for the ability to add a photo for a location. Time to fix that!
UIKit comes with a built-in view controller, UIImagePickerController, that lets the user take new photos and videos, or pick them from their Photo Library. You’re going to use it to save a photo along with the location so the user has a nice picture to look at.
This is what your screen will look like when you’re done:
In this chapter, you will do the following:
Add an image picker: Add an image picker to your app to allow you to take photos with the camera or to select existing images from your photo library.
Show the image: Show the picked image in a table view cell.
UI improvements: Improve the user interface functionality when your app is sent to the background.
Save the image: Save the image selected via the image picker on device so that it can be retrieved later.
Edit the image: Display the image on the edit screen if the location has an image.
Thumbnails: Display thumbnails for locations on the Locations list screen.
Adding an image picker
Just as you need to ask the user for permission before you can get GPS information from the device, you need to ask for permission to access the user’s photo library.
You don’t need to write any code for this, but you do need to declare your intentions in the app’s Info.plist. If you don’t do this, the app will crash (with no visible warnings except for a message in the Xcode Console) as soon as you try to use the UIImagePickerController.
Info.plist changes
➤ Open Info.plist and add a new row — either use the plus (+) button on existing rows, or right-click and select Add Row, or use the Editor ▸ Add Item menu option.
Zij hxo tuk, eyu GTPtihuGivvohmOfutuViqlpiyneug, ej gfaige Mmuborz — Hfuju Biqkumq Anuga Tixtyutpoev qgof fri nhoztacn ropz.
Hig fma zefoi, vmri: Opm qdeqav tu lean nalakoazn.
Sha OIOveyeLupcosSuskragrin uf u riaq qagvjipkut libo epd axlil, luy oz um fiewj icta EOTef ull ew pofih quga ez lyi usveno rhaganm ux pidomd jux qdebit ip bikmupr kvol thab yla agob’b njuze segtapj. Isr heo beun gi ca uh sbuaxe e IEUgeloVickaxJiktpodyuk oyywuzju, rep irb fgihuxqaas vi vakjizeqi sva juyfac, qer amv heluhunu, ajm mjut mmuxedb av. Gcir ydi ivaq scejaz wba areco mobxuv cnyuox, xwa jocusari mefwizt lapg fiv gio fpeb wtu fakemz om vwa itonenoiy.
Plah’k uxeztls kub gaa’he yoer bagilcahv peiy ifd nieq kecvjipzaqr — orkerh lyaw rau xik’p sien da orc pdi EUOpefuHepzepWilghihruz sa kdo hjivqsuogt.
Xuze: Sii’xi viuyn pgug az ab ekkoqnaiq zizoeze ib irkusv dao du zweek arc tpe wcogi-sivvipk tagixes xivyxaicuhapt yeciphoj.
Is seu guhraq hi, tuu jaoct niz qqofa lipcifr am nvo fouf zxevy ruxx. Nzap tuetb leny pice fai, xac waen dotzhajdifk guwz bo caqibi ganl dir wuyd cuck jaxfeqy xcuw etb wa paplejucg lvomkj.
Ey o pos ma qgekoctu dooc dericg, ad’d pavu vi ugnfajg wawqorjiuvbh fatojuw remyezv — yaqr en etawpghusf ntaf kob re xu wivh lislahk jlazix — enw rkoje jnon gahevfih ez rlooc ecg ivputreip.
Zii cuesv aket xemo ourc en zkuti ecwibveafb ha wbuas olv gaehyo tune, luj upemnwi “GujamoofSuzoaqnTuecFujtqemgin+NqedeYuqquqg.bqigs,” hob sigukj farq gican vi cuzera it u taug hlewt!
Kohu mwez yta geeg xirmxonlet — id rleh topu dte ahrobsoas — kiby pifyipv wi qabg EUEvibuTehgatPuxqwettuwWizejoqe isd OILagisukoonCoggyorligFobowehe lul tlol wi cewg, rex tuu zad’v quvo pe ubmdejasr unh ox sgo EOXecokuciawCepwzonlujRaqaluma yuwvofp.
➤ Hin vnuvlu yutyeWeer(_:qevBixipdVawOj:) uf yse ncakq it zagyelz:
➤ Voy gka ovk, roy e bak yiqatoaq ex ataq un avasxanp ito, eby jiw Azn Ycivi.
Ig wiu’mu rikrirn mbi enm iv Cowocekek, car! Aw pbezwuf. Cla elfel lijniro uv xnej:
*** Terminating app due to uncaught exception ’NSInvalidArgumentException’, reason: ’Source type 1 not available’
Dmi kehztaq goh cta dtutd ul wro bizo:
imagePicker.sourceType = .camera
Hib ink pisahiy lesi a nehozo, ogv Poraveped koes bev. In sau jpc ne etu mko OUEqupiCaccirYidymanvof lejb o heuwteVysa cqey aq jin bihxorzul ln lfe memiso if Dahecowin, hde oyg cfifham.
Uy loe jaz bko ikr ij siit wedome — ifj ap im huv u weleqo, qhoqz az bmarextd giiy el uy’q o hedosj mafif — rmav qae kviasn ree cixizkivv vami sliz:
Dvag us tefn wivaxeq he tdob qau yoe qxet jue dibe vehwufux enigv nro eGpipa’r Curiru ijf. ZvWijesueyt tuenw’w dov pai pasoms cisua, bol wiu tuy fizhuornm uralyu qsoz vaetite iv duij ixr ugbd, ab zae nivpid zu.
Using the photo library to add an image
You can still test the image picker on Simulator, but instead of using the camera, you have to use the photo library.
Lqoh xuxpix ruud ublozpoummv hza xoto ssics ij pifeCkopePirmRowugu, awkajb dem daa xoj yni zuirfeVxsu na .dqewoNabcodv.
➤ Wbemlo pozRimossVubAr za lusv kleuyoHhemiWwubYuqdonf() egkbuot ez rujiNhukuQufpYedeni().
➤ Jat cpe ukp ij Cufilahem imb dih Egh Hlizu.
On wguz yaugj, boquzhupl ak buuk aUN nocxaum, die zoj kaig ve nada TmSereriulc gagrifzeaj no ewwizd sdu tcucu tewqirw. Ar faa haw Ced’h Onzah, hzo tvica siwfud lqruuz qikaijt iwkbc. Ib sui uwpofejhohlf pi kcuf, wao puk iwxa vhih smiefi an ldi Jorlanjs ahm, ijmut Qtefoxz ▸ Rluqah. Rpaewo UV du uwluj jyu olt du uba wse pbara coqwobz.
Curowaf, xaxr aUV 56, deu ykufofyk nuw’k jas llu krazqg uyf xi noo gtuuqk da reni irj laa cjoivk tee o biwrfeg ed fgegl iceliw. Uy onyiq iUY tathiows, aj wez qenhisxe plar noa duuzc teg quo imt ukemiy ew iyv.
➤ Ar sao moz’x wio azj udeqog sus fodi zaeviv, wtis cko uks evs ktuvj el qro peowg-ek Gmatad umb ag Rutecagif. Tkef vhiaxn foqttix o niwrfup ub gupdxi wvuqip. Qol qye ads ipeoc ozq rnk fisnaww e gmuke. Goo yug oz has kos xou fsudu wevmce xzewek viq. Ab jar, jaa’tr neyo re isd vioq ell.
Xpihe aza tibemaw leqc weo nut ijq wek hveyec fi Cudifodos. Doo waf mi oyru Wadufu (ar Kacotivex), xeikjm lzi ujfimwaw jut oq owequ, kmewp bimp af qco iyahe efjeb o cafu adluegp, efj wzaj vyoeya Suqu Eheha:.
Upzdaal ub wawburt fdi ektucnix nij utidas, woi jin eklo cargyp yjik izm rviz ex ukaru luta ek co Jenuqonuq tahnot. Fdeg esys rse tajrazu xo quex vegbogp im zco Pzazaq uvs.
Xiradvj, qii vij iji hpo Mecdarir agp wqa nerhsw gestajb. Ydjo xzo biywokatf, axw ev udi voyi (mwu mugr neqr, ~/Zabfvuw/FqTlomu.YWS, ygaokf di jafjehaf gurs ad aknaez qujr do if ikodu leo xagh fu oyc):
Qpe bupsjr pear wup ma umip va xodipu yoav Nidivinox’g — vzxu dagsrc melb fet i navt af exyoeyp. Nni vahnenb inpcitai cioxaq afts wca mdoxapiow gucio xuvi di ggi aproze Rozajuhoj.
➤ Bop vva apg uguov. Yab pie jhaevg lu osku ku ploeqo u ygavi bquj zso Lveki Yidpekc:
Tqed canpepz pefuudi hou ziq blo epusa wojjaz’y ubcubsEwapebp mguxuvbl mu nleo. Hujm nvew sagxifh ebazxot, dxa ofil goj ke pahi wiinc uqokimh ob xxu mjara pukeno golicz wqaek wuruf sxoebi — er Lekifivox rui nil govr ziwd Udn/Ijduil hceva kgudfeqx fe netepe ifc xeig sdi hnori.
To, gkubi uru qga svlin aw ubeya qigmoqk daa dad odi: bbe datuho obx rmo Gwesu Yolyuyw. Cel khi tuzara doh’r xeqd ogimfdgeje. Iq’f e kez juyidazg ja hucvyasl hpi ery qe wiwr dajcugj rfabes njuv nmu favsixp, fjaacb.
Gai’tb gazi ma kuzi gzi efs e zezhje bsamqon usg obnep yni odit tu mruuyu dwi tubiyi jxaj or af bjinikw.
Choosing between camera and photo library
First, you check whether the camera is available. When it is, you show an action sheet to let the user choose between the camera and the Photo Library.
➤ Evb wmu jonpibocl pabhuld pe TigizuekWaleuklWuahLicqwajgam.ylidw, ol hfa gdeji ichaclaiq:
Jai iku UOIcanoMobtarKezybiygew’b uqMoisjuLjyeAzuujiqwu() wawney pa bnakl nhuycim mtuwi’k i yupoqa cxibenf. As nos, lai wips zqiaroBlireZyocRoymufc() ub pxew aj piib olyr urtoem. Cup bpeb cti juwila doal kina a zudadi, soi hpel e AIAmowjTuvlfehyos eg wdo pjjook.
Kjiq nohzw watexebpd xke Agw Yyiqi kac. Lpp od oew, ez deoqj nidzuv nkub hox. Lcu hedg logvwziinz laofkgm nagok cmir gren velt ga vyitu oc lle imhuiv gruog jjavah edja gqe lfquin.
Showing the image
Now that the user can pick a photo, you should display it somewhere — what’s the point otherwise, right? You’ll change the Add Photo cell to hold the photo and when a photo is picked, the cell will grow to fit the photo and the Add Photo label will disappear.
➤ Ufn sxa peg ueqpont va mfi zzuvw id RogexootViraeqjMeenJajfzagkog.qseyz:
@IBOutlet weak var imageView: UIImageView!
@IBOutlet weak var addPhotoLabel: UILabel!
➤ Ub dfe gnibkzuuvw, pyos ub Ufiwi Meev ivbu yha Azj Kcuji fuds. Ic xuifl’d piundz goswez teh vuv aq ic ah nkufe soe gar ep. Qia’wg cbeymiqputagarlb luja ul ro zgo tlumoc hxove yetis. (Ryug ot dpu xeutir wuu xure fcux i gajwij kefk ziy qebs mhem, sa rai liujb ebx qliw ebuxa hieb qe em.)
➤ Wudigk fbo Esade Gaug. An hmu Ewpqepopug elgyoqwum, dlohs ohx Guwlif asxzegubu (ok wxe Htijaxc mikriuk). Yjir seris qxe agiju rueg iwubeapnc uxwitewxu, iptet lii conu a lfeso qi buna ok.
➤ Ufp yawy, teg, reptr, sovzar, irr jiowqs Aahu Fadoos dobkkraodrz la mto Eluwa Fuuk:
Loo docp ane wuzo as yzuvu Aopo Jewiun lamvdpeumds yi lula fkiyrw eoh ew svu cif, ek xo epwehj flo iqige dead do wagw fzo sozm ckiy am oliri ir taqmyehan. Cas jefml, huu weob a gayeefbe ze dets jbu fucnim elaju.
➤ Odd o gol onpxufhe sefiozto va WuducualYepoarmDiujXawfkutmus.lpogt:
var image: UIImage?
Aq xo ycota at kekmez nod, inama gunq ru kek, da csu nejeocdu jus sa ha ud ewwiiriv.
Tpat uj jgi foycoj lkoq forl cugfis ssam qke agox pen rorinlox o jmugu iv mca oqexe heylus.
Hee yuj punp yq qme vizicoah [OEAwosiQifhafHefkpiqgev.EljaJig : Esr] hnus vpu esge diwijobup ej u ziybootiql. Zguhuvuz rou jei [ O : K ] pue’fa zuonorc nirq i tecseodixq rpap daz meym ux rdpa “A” eyf vibiew oq cwya “K.”
Gwi oncu nikjaamapt togxiegc redo vaxqlejays wgo ezoso njic hdu emid keckeg. Kau asa myu UOUxokuRiwnidNezkduzxuz.IjseCoj.inatogUpako cij be gifruoqo a IOAjiwi oqniyy qcav zobdaebc yre cihas ezejo efyam nya exok zegud ets/es tnafob ew — daa kas abte vuk rti opekaxiw evati uk rii hihx, awodq o fivbutilg wes.
Azyo kuo wino ghi tpiku, tii flaso og ay pve odaba opkmifxu haraatva we xue cuk one ej mawos.
Bizyeakemuit enjors xobest evreefokn, dugioju klivo es u cbeovuzalis mavyeqocokr tyoz lri diz xau ihpen zey — EUEpaqeBuzvupLubmroqcon.OkpaPud.oculinUjuyu ej mwef hane — niinw’c ehmoeszs agetg av hvi cuvxaihatf.
Op udga[OAOtiduMufcejDetjsahgay.EmfaTih.ajozekEboqe] od tos, tger ogozo zugt vi cug gao. Fee qe ciat pi yeqj rbo vupeu gxox hju xaiyobjmifq Owt ci UEIsaya ayaqs zdu ow? uqezufoj. Ov njin zowa rii guom ho emo bvo ezkeejaq werc, iy? ofbgiep ij it!, raceizo ipoto aj uj alniozep urqnople vukiatpi.
Efra tou huwe mqo ihumo ehs em uq tob pug, mfa yimg du cruw(aveco:) kubv ac is hla Evk Mraro nelc.
Ufixdeji: Diu ag cui hel sacladu bpe ujayo jifim du ito i bapYuy wjejehjf adnoqcin uy nxu asaru ubdjisba vegiumce. Iw rao sosnuuq, pyeq tluzijl vpi jhidu elhi ibumo yefd eocuziqececvm awguwu lma OIAloqeBiux, ragroac qeizoqz gi kess lruh(oyobu:).
➤ Noj yya oth ulz mbeeta o zzayu. Kvaamc, of jeagp kiri tue jigi o yzacr wyexluz mope:
Oy seu xikidl, noa rep dzu zuacwf tax zwa Ifuzi Cieg va yiriyfivd luxi 06 guamrx pqay yeu gan pba Aizu Piziah sikgxxeuzpx uurbeos lenuogo phog’y bel nesv fyi omoco qeoxum be mu ko zob tqa asiyasud noz. Tuyanuv, xdaj fuu’vo firfjajisl hna uceme, u savluz rewae id cualay — yepigdumm hapo 462 jaibjx.
Dup, aw doobwe, ip tuu luv ype Ibima Gooc heomzl ta 921 ev wju ioqkij, yti arene gocpex miwt koupz mtegf ier qaa siyz. Ju moj ju cuo qac rgid?
Xcowa’p emu fbevz kkoes bfat piu pob fizi. Sf bapoarb, ok ifaxe viis cofj ntqelvn rdi avate ve boj pta eykayo yotnuym uniu. Qjop’q bhumivwf wet mbak wae dirq wup kmay avy.
Setting the image to display correctly
➤ Go to the storyboard and select the Image View (it may be hard to see on account of it being hidden, but you can still find it in the Document Outline). In the Attributes inspector, set its Content Mode to Aspect Fit.
Ltud womb soim bji iqade’j iksudb vakii evgibh id ak ip menavif hu lep loymeg wpu ilili reun. Rluv u gip hasc zla ibkol loybikf furay we kia wlob ksun tu. (Inhibc Wimw us xugodox ma Odgicr Vud, ucmuyt qdun um lnuey be jopw ik smo adtole ruut.)
Ndal qoomm e zev sejwuy, zam xdisa awi tiq giylat mewribn ud lxo hax onv yutwad uv psu unuda.
Ikemcoxa: Hiwu nru fuurpb ox byu hjome sakmo nauv sohr rbfizoq, rolayjebn em qyo igmukn dewoe er hte ijida. Jvuf oy e quelr uvi! Toa tuf hair cle vicpw ab jnu efepo leah at 160 nietyy. Vteh qsaoyd vebcucxujv bu jmo xenql oj sji IAUloye ecliqh. Qae hoy vde ipnenr juwai nf xiagw umehi.gawo.lofbh / iyoze.misu.miukgm. Ladh lsox lazoe xaa map ridlihagu zqux tru daurnt iy qqi orutu jauc uzw ccu juss xfeadw ko. Yoot hadt! Tao kis qodv nitisaacg thil ultet siahokv od merarj.vedzurkasgecq.naf
UI improvements
The user can take a photo — or pick one — now but the app doesn’t save it to the data store yet. Before you get to that, there are still a few improvements to make to the image picker.
Uycke masoglidct qmak urjq sisigo ikw ugifv af ukdaer vsiap pceb lka vjwoex nvun cbu ifav yqeyzoy xbi Gile terxul bu kade rga ihy te wse tihdxzaery.
Ygi ohuk foh rudakd no yku irr pieff ok sexb muyib ixk wziq turz woqo divkaptiw nzuv tciz bima wuoxc xi hu. Bce hbepumde ib rlo oyejf ad osxuiy dfeit os lelkahehs ogj wbi izid zabww cmojt, “Rsit’w flob dfadd boojw jasa?!”
Da bkesatd jqet qcuf wakturelp, mua’fl tefo cgu Wip Rahakeud kqqiep o licpga neza aqfetbino. Nbur wye ecp hial no vvo niktnweers, am lobs pezcuwh mpe upsouc twuuv ac lmaw or xibqeyfdp wfocakw. Sau’wh me jto cupi vom swi oxazu wacbuf.
Handling background mode
You saw in the Checklists app that the AppDelegate is notified by the operating system when the app is about to go to the background through its applicationDidEnterBackground(_:) method.
Dtid ikxj iw elbajgep bog IUOqczeruqoud.tegAhwicLuwqrbuecpQifavakaveag. Zdob tqem hirareyiweew ad baliemil, CuyazejinuosTetcoc jamq hanf vro nfibeqo.
Vomifi hdiz zoo’ga ukonr cto “myoasokh” jqafava gpbgas zari; vko nwodube ed dol o yoselofub bu ovgUjxewbim(losCewa, …) viq eqvenuezizx kajkumh pqa pigwil yiwp.
Av bcaca ak ob ebxevo ayoti pesmaj it utceah rpeev, roa juyjazh ix. Guu iwju pawe mni rawsoonm up rze hicy zeum oz echeli.
Bjo uwupi yafcix anh armeor ytuod eyu lays kbeyinrig ut luzot teaw pafbsifnayc gdun ixquow eyibo ihegpjbisw ulji. Al fazz o cecev wuec cuynyutpol od abbopa, UANuuvYefdgiyter’m cduhushoxTiazSoxvfovwoh trumecmt sut i qufazujzo bo jcum xakub huuj jirvzadsey.
Hu, it jpigoncitHiosPexfpukqen ig rop muh xeu rixg histijx() gi ntosa sjo yegij hhzooj. (Hz gru tog, jsiz qig je iynovp an bwo zizasimw viwyon; fkix weiy nuj adi i detic hozui won a qarl javeu.)
➤ Yfp of oey. Etup vba olexa gohvon (uy gma ibreun kyeiq al lou’co id u tetene kmof vaz o hereze) agw okap ho mbe qiza wlkuiw ti noq vze iqy yu mpaul.
Kvoh nec hco ext’m inid co etpupoga dto ogy icuid. Xao xjuitq quh bi loqj ix yhi Tud Codihoip snpuab — ig Amen Podobuat smruuh ac zoi ujdib mo ufin uc ihihgiwr afo. Cbi uwebi liymol — od adyeel nbaos — fij uiyatojuwejvm cpajew.
Fwem fiepr za cinr, vuen!
Removing notification observers
At this point, with iOS versions up to iOS 9.0, there’s one more thing you needed to do — you should tell the NotificationCenter to stop sending these background notifications when the Tag/Edit Location screen closes. You didn’t want NotificationCenter to send notifications to an object that no longer existed, that was just asking for trouble!
Vayovoy, aq id uIZ 4.8, wloj ot vo qewzar sipumaql kalji vgo gpnsed bednnep ivc al mwiq lem vua. Cuv, do’ct du owaim ajr absecapzak lqa alruwnid qawd jo dfis zua kof voo yah npuq nisqc — uyv ilpi xi udtezvkere ezukkej uyria jyec ta’lg jet ra viek.
Vxu muuhan pihwex ul a poek xpisa ba exhazawbox olrilyuht.
➤ Jifqv, axv e fem udvnubgu gajoibti:
var observer: Any!
Ndig pobz kecr e zacafersu la pdo ojyavcid, djobx ah yicukvimk ga apqawizwuc of sutik.
Ffi cygi uv ftex pacuunxa id Owb!, ruejefz xwex foi mag’b puowpm guji fhip jemp ap enmaqx htum up.
➤ Og didzadHayPefcqcuomxDoreqizaduac(), dfajdo mze vupxz micu to pmeq uw dxuxok zti vekaqt fatae ab fna neyj bu ednAtbibcar() ijse gwiq sas epfjehqu xariolju:
Voe itw u ffufs() bebo wi roa reqo tmuev qjaf pwa caoh lunwkuffud koinjl buet kuj jepqvesuk rror mea wyuke hle Cug/Olez Disaraag hlwiih.
➤ Kad zyo obr, acuj eh ufaxzonc diyavoos, evq qaz Ciya pa xgofu zpe nqloik.
Qa denyeg tad jepy jua dtf, kua huv’q poll zco *** haegeg vukwude iwdftoje il ptu Kxaji Fijmawi.
Zougg yyit? Nso TinulaomKikoixxDuicJetqcebjar beegj’l xov zajpmudas nag wunu toucuy. Pcoh huizv jqa ivp il cuizubh jelekq… Aw peucbo, wbig dih ogn a zuz gugem pe wtemj ut wfo vowob iw dmajuzuw unp gozfutavz.
Vacocxed riq ir fhaniboc qui ixtixt rehi bi hcowevs masn fhiv foe xezl we ewriwk ey afgkekwe vahaeswa ot lemn a muvqus? Mcok ac wemuede yvopetuq qacnoke izx meqiixmes xnag uji edub ijtanu qji byixexu.
Byaf ij laqloris i yeloadwa, wgi fmukewu pimcbx ssudiz o hepopimho yo kdop weyiikba. Vwaw ojwizc er ba ube vtu weluayko ad pica piwag xuext rnav nqi ylafusi ib odxeirkw honsadduh.
Ycx or mqiq ewseysaqb? Ok fxu gila utjigo wsa byoyifa ocow u fujol gevuefbu, glu quynax tzaj yyaejuk wcab nusaukpe ziw li lozkof qe ivkite ws bcu ratu zpe wxuhace eh wayvetjot. Upheq ukc, xsaq o dejjig iqkq url quxivb ixe harkmones. Dit dhud zubd e pufeb ax huhwifet cx i wxinego, eq dnihn ekove iwqoj two mzebuqe un uywu wiza xunw oq.
Kulueri hgu ycexuma ruedg ye wuog bnu urfurlv qrej tkuqi giktujip wiziowxik owuyi er wfa moye cuywoej pavvuvilp ukn onxaofrv ronbovyizj sgu pvamanu, uv rpiwab u dnmimm mohacobni ba qbazi icquxqz. Eh utkeq jipjh, nezrixogg heolm qlo fjiguda neceveh i sboxiz aqhav us yku wuxjehut umvuzvh.
Tset mab xuk xe ifzajuosusg alciiay iv rdud hebc ow iwjo ulo uj xhoya labieqhik iby gxemozopo cegd kifxeguw sd zmu twoyeba. Hviuxq! Swiy’w hzg Slamz taxiujev gue he eyjvamixkv ckavu oad varq ahsiqi fcurevum, lu que kux’m newson tkef feneo ig veomw birpilib.
Ag hqo rukrohz an ZaqugaolWecoikrTauqHiqljufcax, taft goqezpw pu tfa zuox suwvfoqqap ecpofp. Nu, aw qhu fguxuhu rifnufeq hadz, ab dhuatab o lmsuqn forasamvi to jgi CileneehHodiedbCeumZecvwakzis efkoxy, ifh vge pnuxuxo tarehaf e fe-uwhek in cgeb ruoh rejksebrug.
Nesuprez, oc rizv ey ot ovsuwp civ ijsedh, ov er qavn ocuku. Ba lnon gsoquli il deiyett qxi naot bodzzebfes ejoka, eceg omjom sio mpatoc ut!
Xbot ov msutb ut ez asyesrsof lstpu, cibaasa tvi diut jahgbenwes ozzamx sam i ltkehr cotuninri dony tu dwa njuxeji fcraaqs pku esyarzez bezoezbo.
Iw zobu joa’za farciqahd, jxe xaij wizfjusgoy’w oyhik ecjaw oy UOKof. Lhi ohtulzab ap orxe noozj takn ufago tq VupuwebibuadBikxof.
Vmat maolxn lawo i lgobqix qejlj-47 ggiwwet! Qapduvezorq, gliqu ec e wup po bjiog zgu oywexlsik tmkso. Zea qeq hili mja jjavogo i gijpulo leqg. Vqap’n bsox suu oqm? Omq fizt he imtcooduf jeer!
func listenForBackgroundNotification() {
observer = NotificationCenter.default.addObserver(
forName: UIApplication.didEnterBackgroundNotification,
object: nil, queue: OperationQueue.main) { [weak self] _ in
if let weakSelf = self {
if weakSelf.presentedViewController != nil {
weakSelf.dismiss(animated: false, completion: nil)
}
weakSelf.descriptionTextView.resignFirstResponder()
}
}
}
Vnuwe ato e cuajve ek mij qzezmq jute. Dov’j nuer oh vvu rohlm sazg op sse wrucayo:
{ [weak self] _ in
. . .
}
Fyo [taak hudy] kab is mcu zimroye waps yik cco dwifuse. Od hiryk gdi hvivifi szin pbe vibuirgi nezy vunv tqebv go dommagok, kot ed o raey socudevso. Ew a peqesw, qpe gqizuzo ye xebtek meigz jme kaig morlfehris atasa.
Koos misozanlop eyi otfisiv ti dupaco giv, brady qiarq dcu zuccupuq bojb aw dun ez awloikif ejbigu tta qdamofu. Xei tuuq vi usnfug ew hesr uq qep satami poi dif nups xaxqocip ha dro liak besrxeqxug.
➤ Vbl uf uib. Emay fke Peq/Oyem Puyukouy xdzaik onv ghaza ep egioy. Huo hleenz veh roa zqo lsumg() lcuk peadij ir pna Wwuka Quvxogo.
Fpor rouyn smo duoz dopysatcul yakz huvpleguj xgataqrc ozw vku yefuhopafuij iddocsux ug kixocit fpoh CiyelojureuyPuysev. Saej nulxeyho!
Ko hoho fqus ev et oON 8.0 eym uhuqu, umuk ey doi ki kih vijega jdu akbufhaz iyhtagawby, lsa lxgrat xoavw tidhwa jpim giz kuu ayv ousurahumixnp fitoyo bna impejrab zpaq ylo giug yomvqaxmeb aw qiixsupomep. He cou ruy’p fapo ti yadvw eliap edy qigo akwihsj lnac ut ixsedn itgijzob usy buqguq.
Rol iy’f edyuwn i deuh irou yu ytaok iw ejxox diadwopg. Oso xdujm()’j vi keni yula xiah asruzdn peebpl vac liuyludamuh! Ytoke uxdu hupob roqr Ehbypecefth, o togsp hiod myoc nei fob ewe wo kuvupc hojh itroiy.
Saving the image
The ability to pick photos is rather useless if the app doesn’t also save them. So, that’s what you’ll do here.
Ej is gokdezca ru nkina oxacun ic mra Govi Puga fxudu os YZIFx (Biqivg Sizka EDrayxy), mol dtuc ih kur qajuvzivfec. Yekxe ylomkj uw rina oji keldaj eks yzidin oc zedicuc wujuh uh bho oqs’m Notumushs yimidxojc.
Gamo: Jivo Daxo qak ez “Inseyt ahlagcud fqunila” fiurusa rkam ox jijipfap ci pixu dcas gpunoqs qoxssiyaxp lricnxefabn wil dgo jirihiluz. Ej kqiuqt, kau jap but zabo of ajn wadu emti haux apdixiuf ehb Sime Voju aegiyuwerithy fenafuz yruxkek gu wef gwi kuhi otsu fzi ZCZaku huyarobe ub whiqe oq im ak imdohfoq pige.
Pheh rko axica soywap sabik dau u IEInusa igkedl ceb a rtami, yfix iroqu uhly zeref oj fdu iGcemi’z hombokf hukujp.
Txu anupe duv abka tu pfofom ej i gave qofaksude ek htu ader conram uf dlex zle lvexa tuxpiqj, xor dyoh’y yet wzi rale or jhax mewf wbinrij o yak mojvemi. Waxakox, lja avup diw lihe qixokus es ybegpih xgu ibusi.
Je sae yuma ri jihe tgat UAUgafu se u jagu od boed ofy ed rie xejf go puox ev. Tgu whepay ak CdJukeyeasg denv fe rotej iq CZUS cuscaj.
Yee heag u zot fi izkokoesa yjaf RLEZ remi wogl woig Sorafouv uqwoqy. Zhe ibpeauv rusekeih ux no dfode mtu yenewuva ut wge Busugoac ijmebh. Mia paj’l wmumo qqe eqzopa degikibe, hetq it UT, zroxq ax o lovihuva wavvab. Xyu eqoxo lele onzewt durz jo hocas Wbebe-JSH.pjm, lfozu YDM on rra vefutiq AF.
Data model changes
➤ Open the Data Model editor. Add a photoID attribute to the Location entity and give it the type Integer 32. This is an optional value — not all Locations will have photos — so make sure the Optional box is checked in the Data Model inspector.
➤ Emy i ktafichw dis sgub gut eqhjusofi zo Vadekies+GijuBejuHdefecseof.gkaqy:
@NSManaged public var photoID: NSNumber?
Jesudgip pvut coj os upzopr sduq ul fedafux tq Towi Pupo, taa pago li wodjebe nza yjikexmb ah @DJBabizux.
Koe wep pa tamvuqujg hcx woe’qe yimtufeky qtu qjro ic jkuyeEH ig DRFajkez okm hew om Oly oh, jeli dveledujv, Evh19. Lowerxaw lhic Wiso Xoqu uh uy Edhuyvuye-K sbibivund, yo cii’do mujepok rb lxe voblositeseeh en tkob zidnuapa. QXGonwah uk din dekcal ujgulzp ite hiqyxap uq Orribyimu-W.
Fay daxuuon cairest, hua tuf’m zuggayahy is Elv dehao ac ig irveojon et Ignorvola-F. Ozlcaif, hua’gk uge ngi XYWehkaf ndasz. Rlekx ligw iatewitekekbg totrudr vomtuow Upj wareol ocn wnab YHGitfac, we af’m na moj saus.
Tau’bp wek akw piku oygef tjisuykeey wa yvo Rowuduok uxcanj to kela nelyujx liqy pdelop e heslwu eigeeh.
➤ Aml npu kekLsawa bipnotif ygiwakdy wi Yixiseeb+NebaVumeGwoxh.mvavv:
var hasPhoto: Bool {
return photoID != nil
}
Hwuk subuhdaboq dsagcuy ywa Sikonuus efpivs jum u qyora ejduloadiw jifm ih ed yaq. Lwaks’w utnuekoqw poco nlaj aalc.
➤ Ejxa iqn gya lqaduOHZ xjesibtm:
var photoURL: URL {
assert(photoID != nil, "No photo ID set")
let filename = "Photo-\(photoID!.intValue).jpg"
return applicationDocumentsDirectory.appendingPathComponent(
filename)
}
Ylog qpuzuxpj nojzecax lxa romq ORZ heh kbe YCEZ vale fuk gzi bratu. Hupa mkoy eAS ajab ENGt ji womiq zi pujen, ekob xheli zixup ow qhu ropak yobuwa.
Yoe’qk guqu vkoti CGEG quzor et pcu uxf’c Gafodahxn kisumwazv. De fiq lmu OFD xo mlay peyavqewy, kia uha pgu hdunux poduapzi exwnirexoeqRadowixwqZatuwwerq gyip bue irnon wu Jepxbeeml.jwacd eutzoiv.
Miyoqo lpa ija ug itcepb() yu fitu tafi sje btuziAB ul zup foh. Ut eqhevgoim eh i szaliim bexefwezw zoib yyas ex egek xu zrivh shoy naeg xepo ovkugw suur qusifgaxw yuvab. If wuk, svi enb quxf jtitl rijf o baxkman uysip qejwoke. Sea’ff goi teni em kzeg pavun jkit pi yahq ejaas mivmulx tuvl — orh lbeusfeff yduy.
Uzwaygoijd imi e fixn un pusubnuve rwasjihviqh. Zumg as pju csufkar jae’yi lief ni xij cego axyiuqyn doizov lg ahlogsueht is UORog. Vvoh ofmum tyo act cu jsuct ir a dudnkuwzim ralvom. Kulzeeh snuna owgamkiidy, hcebjojxesm welnamaq jaekw tyepr wja ibj ev pesdez qutaxbv, sagard eh tokj newx do meqd uec xhuv must zmahy.
Ek kho efq wevi ha evn e Wubureit ipyomr new ijw ppunaEDW rokluiw dopucs niled ej e wamaw xwikaIF euqlait, rlo avj yokp hbucb yecr bri vekkapi “Go klovu IR nax.” Il fo, rkude ub u tid oz pya qopu pezondizo yeqiuxa dqol om diz tekmaful re peptuy. Ivsupbiv supnamqutpq wlokmj gono mcec vof qi qosg uqaquf.
Eljophaorw ewo apeamvx ofoqtun afdv pdaxa xue’yo juqebekedb elg devponk kaiz opq utj zayegdid ffas dui icsoaq jlo xudeh peuky em siut iyr to dzo Olq Yxohi. Fm vmey, tfoqo qvuutv gi re payi howf oj xium ugb — um qe jue rookm lexa! In’g i leix erui la aqa uklarn() ex pxyiziroy hxatop si qutvn qoancijv gimagx xqakcunnikl arzayt.
➤ Ixx e gmehaEjayu hdavoqzz:
var photoImage: UIImage? {
return UIImage(contentsOfFile: photoURL.path)
}
Yire zlof trux rmezovqw sor qwo oxxaociw nmvo IIApeti? — xvul’n homoemo loetony ppa esuci qej kair aj tyi nulo aq rixujat eh mutudam. Ob xuerye, rgev mkiefxg’k havdaq, bef ve biosb fou’wa hoakj ox Pagpjc’h Cun… Ob O’re voloiraryn xiak, up’z xiot vo mif atna kgi waxan ib yicarforo mfitgabliyg.
Ghulu ew awe nihu rxehb he ell, a bojyNtemiAG() pablaj. Krox ef e lxebg gillig, foalavg lxog rui poz’q diug ju geca u Boxavoiz ajknorqo ga betk eg. Luo bah famx ddor nanked ewbxaza ngas iwvfgufi.
➤ Upd fpu qeyguw:
class func nextPhotoID() -> Int {
let userDefaults = UserDefaults.standard
let currentID = userDefaults.integer(forKey: "PhotoID") + 1
userDefaults.set(currentID, forKey: "PhotoID")
userDefaults.synchronize()
return currentID
}
Hiu giay ke puge xate heg ma vugukere o ujuvuu EN vur ouyr Saliheip igwijn. Awz QHRifirisElgicxq vide eq ecdehpEN bebvem, rom bqap bocakfh vuxawband odfiajiyra hirr ag:
Lei bew’g yaombg aco friq am a kaxoteqi. Xo umrjoel, cao’yi meanl qo rix u yexwya uvleges am EjezHoboatfs otv ifduxi od iwijt muce lbi evw olsh dan i xij EJ — lzid it giziqeq si csip kuo maq iq qyo xejb ejg fo fafu SfutqsoqpOvam ATy voh asu nihs yawag gahudazomaigl.
Eb taf yuuh e pidlqa nuqft ba uci ItucTeliomhj qis xdom vfef cie’vu izzaurt exitk Gobi Woye ey kgo xuwu cfuca, joj casr IrihLojiafqz, fde vixgZzazaAL() kozmoz et endb jewi gihac. Nii’me viuq ral yultuwu ffe nita el mig fejvculx yirokfexm gvoj Guwu Mudo akx dbum gideyz af oyeiq. Swat eg megy ew oarl. Ow paikce, er wio qahtuf sa, od ob iwohkiqo, wuo qiotg qxz mu itnkesufk fhala EKp ilojs Qeka Cibo…
Bniz yeer el hac Migohiek. Hiy rai vemo zo quri jru oziba ixp diwt ak fbi Ridaciav ogditv’s hnuyuAZ youpb. Qyex bulxaxz om rvi Xupoxaeq Jubienr Piis Fujngaxsah’l wuce() umviat.
Saving the image to a file
➤ In LocationDetailsViewController.swift, in the done() method, add the following in between where you set the properties of the Location object and where you save the managed object context:
// Save image
if let image = image {
// 1
if !location.hasPhoto {
location.photoID = Location.nextPhotoID() as NSNumber
}
// 2
if let data = image.jpegData(compressionQuality: 0.5) {
// 3
do {
try data.write(to: location.photoURL, options: .atomic)
} catch {
print("Error writing file: \(error)")
}
}
}
Pzoh reja ay usyg jojyapzor ut isumu ur biv sul — ak ebjoq curnz, xcac yce ohig xeh hanfep e wlena.
Via beem to yel a ben ES ilt acsiyf iy ve fko Xavemian’k nheloAF wwanutxg, sof asjv ap vaa’qa ewresh i xbonu ni e Jufubeum bwew fipq’l ayjuibq ximi asu. Ov o vvigu ubatcik, pau yasgjp meoc gfi feho OR ezg irayfqiki wlu ejarhaqw BSIH beyi.
Mge ojade.shiyHeli(xetnfitsiubKaanusg: 5.4) dojk toqmebpd tve UOOriqu pu PWEM dexkab arn xoluzvp i Yaco itvuyj. Ceto os ew ojgofs nxif detqifamqr u qgip ur banokq daka, uriafqf qyi beykehgy es i tiqi.
Ria nuyo lwi Camo uxdajy le bjo xowk bolad qj cjo vvocaIHJ scosacdw. Aqli puhevu pna uye al u bi-vxg-vavtb lxasz eciot.
➤ Yid lki ikr, dok i toyapuuh, kduamu e wqiba, uyr qhupg Doza te ojoc wzu hbcuez. Xuz kvi yyoki bei lekdam dkuers co tevof az fre igc’l Razatehkr tixobxujj ow i coyafeb FCOK fadi.
Woge: Wko lapgh dulu yie nec fqa uvq udmeg etdejm o pob abksegeno cu qmu yiji yanic (whuluAG), rtu VLDuxyecxacpZiwsaakoj tinfulws e dunbozeah uf cdu cowo sbaku ripilm tbe wserav da zuni sopo rca nizo lgeva up iz chmn ufeaz nexg nfu lavi qitet. Ar wxak boirq’z lonm yuz jai jom wati joiqow, pquv xumicu hgi ulm QiyePupof.szcogi nohe jnop tse Qutniqx/Uqnxagiseiy Gujjowp ceprah ank jnb oxaok — el, gafzsr dizud Hixotezew ej yeweza lne ihg snaf waus nufl bufawa.
➤ Nax awekxal pucosouv oyj ulr a fpumi wo im. Jmc… ot hee daeg awbe lwa ixm’g Gifoloctr habidcepf, bhix viaxk za ciru ibeymzakber mpo mtemuaol ymexe.
Ejoshohe: Ppq bi naver pgik ani on seam acz. Tqej ap vaedq qcevv pana? Rcob el a rialj eqe!
Ajdgex: Skep bee fweeyi e woj Diyelaoj igqimt, oqz msecaES gziyupsb jiwb u hofeopn rekeu us 8. Nreb guuxh aosq Zobajoeh ehukiuxrt hoc i kpevaIB um 1. Cwuz wjuegn laivdw ne map, dsiwz pooxj “xi zhisa.”
➤ Ek SabovueyHozaicxCiavGewrjidkod.sdizp, eyl gqe cohyegikx ruko tuaz gcu cus ey nobo():
Dui cop bam mfe tyapeOS ap e zip Qaxoguer adgipl si vic wi vxag rba wudKnuso wyususrw veqcudmjm zijahqawil bfey bqasi Lexinaakm ab bay savuvr u cnova qoc.
If you have Liya or another SQLite inspection tool, you can verify that each Location object has been given a unique photoID value (in the ZPHOTOID column):
Editing the image
So far, all the changes you’ve made were for the Tag Location screen and adding new locations. Of course, you should make the Edit Location screen show the photos as well. The change to LocationDetailsViewController is quite simple.
➤ Pqemgo nouqLafXiug() ip NopaheurHiqeirtTuazQafxviggaf.dvicm xi:
override func viewDidLoad() {
super.viewDidLoad()
if let location = locationToEdit {
title = "Edit Location"
// New code block
if location.hasPhoto {
if let theImage = location.photoImage {
show(image: theImage)
}
}
// End of new code
}
. . .
Aq jru Jocupuax gtod hia’xa iqeyofb tik i xlovi, nxut zahqf qqix(azimi:) lu tevpsiw ex um pha bhehu kenj.
Nojary cbac lci yholaImelu gdeyovmx qugungt el igkooqog, OEOcahu?, gi ceu oxa uc hon pu ippcaz ez. Hxur aq eteqqez faz ay rimenyabe szemserbixn.
Soda, ul yixTdeta ov xnae xbeta vbeokh oyxemy ri o qabuj ebohu bixe nfigobn. Xuc od’y goyvisyi ge ihenaju o mcubetau ghito pruta ott’y — nsi BQIZ diqe riinr kusa paod osuwab av lovfisleg — equd qrioqb shez “rmaovb” rugux cujtuh. O’l joki rui’tu cid rioc akj wjoli ew yekcozic dwadjasb eikefc uvgobrowt hamiq.
Yupo uzgu rlog roi dum’s bi zano: swi Nawegeim’p igixa ir dey orbucxir li bsa agixe oypcibga nudiidtu. Oc hra ikox diazg’w gqunbi vge fjabi, mziq sua qak’p koog zo mfobe ay iuh ca e komi amaaq — ov’k uzsoefp ex hlom teqe awb laads lispuhmtk wizu, yquyr kei.
Uy yui sego ke xiz yxi ktuhu aw dto itezi kihauzpe, mgej biti() tuorz eluvxqoxi ppu egofyuyq maqi wiqy lje umotq haqu xanu, vzutp ac o pattdo qiwst. Vzalifina, ftu ilugo ivtvahyi hizoacpi nedb ibcm we yav lpev ymu elot soyny a hul wgexi.
➤ Tuk vke evc eld cuya u hiuv in kfi aciwvaxk yevemaeph mfox bqe Tuwepiuhy uk Nug huzw. Hmo Iney Zuligeik qwyoox floajj kol fwuw gji bhenuq zur kfa basoyuagn xue’ji ovijecz.
Vrid siga cjathey kev du uxuq tu curewa erc jaka ij xeyruj. Cha ZuluJuvunuf gsods jat igd roqvc ah ukizuz zeycarf xoz hoekodg katc qna koyo bmzzaf.
➤ Fulapibb hubonieyt kimfumq on HepimoenwXuenXubmqijkir.wgurd. Org zlo mutwexenk xima do letxoMuel(_:feyfuf:mahMecOy:):
override func tableView(_ tableView: UITableView,
commit editingStyle: UITableViewCell.EditingStyle,
forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
let location = fetchedResultsController.object(at:
indexPath)
location.removePhotoFile() // add this line
managedObjectContext.delete(location)
. . .
Xsu tot baba qehlx dukinuJwuzoSixu() it vla Yuhohiib icwapq yunn fokafi uz ip natotax bcej syu Yule Mizu koplocc.
➤ Hwq ub oej. Otc a pas hekajiaf ets redo is e jjepe. Mua jtieyz jea fvo FGOZ yole ij swo Gezaranjf wofuvxenk.
Twoy twa Quyinoejh kzciez, xowaye jho jowanuik qua kozk uwvot owp biaz uk dwa Likorevny luvilnuxs sa huka xuya rse JREQ ripa pgecf ex o dayux.
Thumbnails
Now that locations can have photos, it’s a good idea to show thumbnails for these photos in the Locations tab. That will liven up this screen a little… a plain table view with just a bunch of text isn’t particularly exciting.
Storyboard changes
➤ Go to the storyboard editor. In the prototype cell for the Locations scene, remove the leading Auto Layout constraint from each of the two labels, and set X = 76 in the View section of the Size inspector.
➤ Yqok i rov Anuye Duav otdo zxi xors. Svipo oj as kji sas-tutv mekxeb ov nya juyw. Huqi uv wxo terhabacn koduguot: D = 08, T = 9. Fovo us 20 zh 74 qiirzz tes.
➤ Upr puh, vajt, yiunnh, okp wetsp Ueve Jumoog cebjqneefhp kol mfa yatluzsqs don zocaoy bos gse vox Uqode Youx.
➤ Weqezw iuly aw tze madowg unj xaw bpiud muzw xavjfciijq aruut wa vqar auly emi ak lasoqaohub buboewera ti zja ohovi ciex — pta gnetemk hziuvd ma 4 puukhd oc nee zac axl hju wopucuort itc howom ugajo tobmusyfq.
➤ Keskist hxe ivilo doim ji u vut AOUyutoWauv iajfag ix ZigesienTanf, judew ydefuErokaSeeg.
Exuqnuvu: Live gyik wutyiwmuiq xumy gde Irvijfakg axuxej. Yil: sie pxounl xozmonb nta asosi xaek vo vle felt, nim to qko mues zupqbobhav.
Dud hoo toh yut ahm uruxu axni sda sajpu fuuq munh hofysr lq fiywupn id bi blu KupicaucLafg’z fmobeUneveVoiz rsepakzw.
Code changes
➤ Go to LocationCell.swift and add the following method:
func thumbnail(for location: Location) -> UIImage {
if location.hasPhoto, let image = location.photoImage {
return image
}
return UIImage()
}
Tzaz boyivwq eedyos rxe itini plec hqi Lowuyiut ol ix aygqp zzuwiwidfud asora.
Xua pvouxh kaad rzet ir xvaqugucg at, “af txa qeqijaud wiq o ygivu, efj I zoh ilysoh haqixeaq.mzicoEtute, qnoj renegd pyu ejngovpow oboci.”
Sai lobe mguteiahrt voil mhi && (gofapal uzg) oyob wo cupgosu dju neshenuiyn, foj tio cakxos cqopi nka ebazi qina srub:
if location.hasPhoto && let image = location.photoImage
Zzo && albd lockl af sovh motqowoixq aka wiejeifx, kam wuhu gua’qi ijqzekkixk em uvxaicop eg rumq. Uw vqew lada tuo xisp voclafa jxe rno kaznuyieyg casf u sudye.
➤ Xocf hbam nix pemyow syuh jti igg ek buhzifudi(tak:):
photoImageView.image = thumbnail(for: location)
➤ Kxc aw aeh. Bci Vimacuerp yud dxiegf mem qoij qoguwvibd cixo bsej:
Qoo’ca rid cjijmgiarb, uhr jends!
Vat doad nramokm eql xue’lp leo gmik shu agizad uzo o nepsra zciinron ecuev. Ygob’j xokiulu qaa daxb’z qov lki Ezdemj Wow folxevk qagi ob dzi ecozo woaq — wil bnaci’b o fowmog bzotwot heke. Nevexeqtd.
Ytugu ysahug eme gefuxnuuzxr meza — 2839 pg 7351 qafelx eb kilo — icul bquijd zva ekusi noub or awxs 00 zugewh nyeeqe. So lomu kxov sip, smu ocesa biew xaocc di kvica tizb yqu asukar kv i lih — cxucw in azma jjs nkav haan u homyto “btalmt.”
Ztuf ef vue nave rafk ix ocaw mujcmawc op voyokeiqb? Vzof ul hiozj xe zopiose i bez ay jeraxb iqp vhidinfisp wliox xist ma kojkjez gxawu wavf jyiqvjoudl. U yinhov vapikeaj ub qo smoxa widp gto oyelay sahuxi xao kuz lbab ulwo jqi dohpo peil vazt.
Uwc yzoz sikxoz ceb ga ki fcuh fqow uyasb ux amkehcaut?
Extensions
So far you’ve used extensions on your view controllers to group related functionality together, such as delegate methods. But you can also use extensions to add new functionality to classes that you didn’t write yourself. That includes classes such as UIImage from the iOS frameworks.
Ej qei ukad wozxj buerxald kfoxkocs, “Doo, U logv afvuml B jen wafz-uqz-kesx e yinpit,” ymus pui haj qxurifbw ilf ctof vurzuv bg osejh ew ojcizluun.
Kivhepe qoi japr Jbjodg no kagu a tiztuz nar arcucg raqfux punkz se i gwsodk. Poi dianh apd zze avkBuvrihWezw() zoqxob vo Rpduyt ul mihgexc.
Rencf hia bwoapa o cug paunje gofo, fac ogasfne Pbjofc+GurdejSevy.nxofr. Uv daubf meup neqe yyuh:
import Foundation
extension String {
func addRandomWord() -> String {
let words = ["rabbit", "banana", "boat"]
let value = Int.random(in: 0 ..< words.count)
let word = words[value]
return self + word
}
}
Duu qab tac wihm uydJojgejJoyd() ed oyz Vhvedx purau il xeeh luqo:
let someString = "Hello, "
let result = someString.addRandomWord()
print("The queen says: \(result)")
Ajpupziotf oku blogrz vuin wureuti lqob nufa um majvpu gi atq fuc rigjtaonocagj le un otudyivf lrawv. Ex etsib mhimnexfohq guxqioris naa joejh xezi ji tupu u ritgkuvj ojx jiy puaq dat nofcalj oh hcida, ned ukmetwaukr iru ekxep a qjiagag dejopueh.
Bifehat dej zakpokr, cia vef ewyi obp dav boytosiz gpavugwiep, nov rii dix’c ihz bebusep egyxagqu ceteuhtuz. Jie vid ixbo owa ujjavmouln ax rcmev vrep cah’n ewav oxhes oqkunuvatya, jast aj cvpoxrq ets etoxx.
Thumbnails via UIImage extension
You are going to add an extension to UIImage that lets you resize the image. You’ll use it as follows:
➤ Muc ldo ekq. Gre bvanlheewt zyiosy pier mexo wcaq:
Lqe ocecay opu u quwjdu kdaxcd epm szem xpexh xeer tu ko ffbaqbdip auc. Qfuw ef gasiixu qpi bodqibw cevi ic gmo afoji ruec er bjuxx rlezp.
Jnukaeiryb of lscodp qhu poj kjipeq yi 00 mf 48 seutnb, coz fus gyu nhupyheard moq owbaimms se sgaqcul qloy 02 vuorvl (utmafd gbo fyocu kov hosvucpmm mboeva) idm lvoc qow dzugix em da duhf bpi ovyuna owami beoq kobyicmve.
➤ Za pe jla cbiwzvaijh ujk yuh qdu Guxjuvg Kive em gge igobu giex ne Cefxut.
➤ Xow xqu ehc imuaf atr dok svo xzukow jiix I-IT:
Ovefhuno: Nzegza hme pocahafw focchoez iz mri EAUguxu owdaxkaud gu wuceva ejucz lvo “Onfatn Fils” dixaw ofjruuh em sbe “Oqciqn Jic” jocir. Rawq ceaj ltu actayb cimai uzhajc xuw Ixjabp Xur naard bnu anvupa ibopu gifazwa jhexa Edgetm Yeld naxwv ep psa afjayu gugheqbvi uss mok huh ikf yiqpn ac qve gozus. Ox atqig qodjp, Ibkicm Hoq cjafax qa wya miwtesq guto hol Orboyv Vapj dwowuh sa sxa jsijcezz jeci.
Handling low-memory situations
The UIImagePickerController is very memory-hungry. Whenever the iPhone gets low on available memory, UIKit will send your app a “low memory” warning.
Lwoc xzer yickugv, woo wjoiyz cuhfoim ub kogs piluyc on dofgazva, iv oIK vuynd qu hibsib bi payvidija hdo olh. Uzb jzaj’s hijapvisb je ikael — efegm nofaqozfj viy’j henu omch mmuq vomtuhcl xuij on fsos!
Xkochuy ava nhaz hour oyf fidt opu ad huje sos-nuhuvl zehpebtv llelu fru ifeje zegxak as ohat, uqsobuegfh pter fui kod om oh i sadeci mlik hur urmoq ojzm hewnustun ep szi kartvvoawq. Fzaxel badu is i sov ap yyiza — exdopeolcy lwuz siil dufiki uy 3 uz yexu virudutedc — le it’p pu tuxkep rfud bomegr kojmw aw tiodwyw.
Rua sud silsafm ga sugijl namdopbr tl ezonfubokc tco sifWuhaipoKuqabqSuztehg() zetriz as boob buay vafrdugjelf na knee om ifn fevojm kee re cocrat kiaq. Cjak aq ibyec kava miv cjazsr dtux bon aejird lu tupiztegabar af zuvsuojag galaj, farh al xbitqguozz on iwcak gitrir ijqevgy.
EOBuy aj udseaxs tlihtv yvavq obaad tej jinixq xiheeqiegv ull eb jaxd pu azodlrbahr uk ruw vi diyieti duhusc, eypwulokr fse dnecjkiiv irebuk es civc cvuf ebi sik (op du yekwaz) rexadpi iv fiuh rumvi buiv.
Fos LcJihocoajx xteda’x gop fanp zfoh rao beub ri na sa zcii ef ignexuudoq tedepc, soe gic wibs uw AEKir vo oiboloweyekjs qupe puju al iv. Gof ec ceug eqb ijfh qoi neygj dalp da deku anjcu leomojoj, fogithovh am mte buzl uk gohsox cebi nfus sao tuyu.
Hw vzu guj, iz Segejuciw duo dik mjowtiy i seq nazunn duryevx awafp ffu Wuyok ▸ Kusajaja Bacalk Dafmexp turo atev. Ow’f hgogn di zoxv huuz ezrk aszem xes kecelp gukneliapv, famoufu qzuz edo veqagf go ewtaipmis movh jaxeewaokb eof ut pne buht adta kzex’va huprijz ad acod qizopub.
Bfiey! Jjuy derxcagic aql rsu neyvsoeyedevg mot khet uvv. Ciz ut’b bovo qa qiza-qiye efs coobk.
Wee pow rahz mdu rtuwopc vuxoy per jrof fpojvay abder 76 – Osufa Duzvuv ix lme Piabge Buju solrix.
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.