You are going to build MyLocations, an app that uses the Core Location framework to obtain GPS coordinates for the user’s whereabouts, Map Kit to show the user’s favorite locations on a map, the iPhone’s camera and photo library to attach photos to these locations, and finally, Core Data to store everything in a database. Phew, that’s a lot of stuff!
The finished app looks like this:
MyLocations lets you keep a list of spots that you find interesting. Go somewhere with your iPhone or iPod touch and press the “Get My Location” button to obtain GPS coordinates and the corresponding street address. Save this location along with a description and a photo in your list of favorites for reminiscing about the good old days. Think of this app as a “location album” instead of a photo album.
To make the workload easier to handle, you’ll split the project up into smaller chunks:
You will first figure out how to obtain GPS coordinates from the Core Location framework and how to convert these coordinates into an address, a process known as reverse geocoding. Core Location makes this easy, but due to the unpredictable nature of mobile devices, the logic involved can still get quite tricky.
Once you have the coordinates, you’ll create the Tag Location screen that lets users enter the details for the new location. This is a table view controller with static cells, very similar to what you’ve done previously for Checklists.
You’ll store the location data into a Core Data store. For the last app you saved app data into a .plist file, which is fine for simple apps, but pro developers use Core Data. It’s not as scary as it sounds!
Next, you’ll show the locations as pins on a map using the Map Kit framework.
The Tag Location screen has an Add Photo button that you will connect to the iPhone’s camera and photo library so users can add snapshots to their locations.
Finally, you’ll make the app look good using custom graphics. You will also add sound effects and some animations to the mix.
Of course, you are not going to do all of that at once :] In this chapter, you will do the following:
Get GPS Coordinates: Create a tab bar-based app and set up the UI for the first tab.
CoreLocation: Use the CoreLocation framework to get the user’s current location.
Display coordinates: Display location information on screen.
When you’re done with this chapter, the app will look like this:
Get GPS coordinates
First, you’ll create the MyLocations project in Xcode and then use the Core Location framework to find the latitude and longitude of the user’s location.
Create project
➤ Fire up Xcode and make a new project. Choose the App template.
➤ Cirw ow dhi itxuugh ep virmenm:
Truxebs Ruye: XzBexagiipd
Pioz: Muregx ceir meoq (an xoo juca eto), oh yeiye iq Gaxe.
Avi Jawu Xihu: qqaxkal (nou’cm feafm hbab hlaj odniot wiux ok Fbogbug 72)
Zewk it CqeexKes: ecnwerpal
Aylluyi Bilsl: axjvifrel
➤ Jiru wni tlohacq.
Un bou ruh zka akq, goa jorp gic e nnivp yhucu vcviug — detg eb tii pup suyg ziab jgeyueom kgo imxd.
The Tabbed Interface
We are going to have a tabbed interface for MyLocations. That means that the opening screen should actually show a tab bar along the bottom of the screen. How do we go from the blank white screen to a tabbed interface?
➤ Ja no yra Wlofixs Johwoxhn xyriis’j Docefuq gih okh makelc cfa Fafgsaiy maynepx oyjox Pajgexjebq Ijvi - Foware Atuiwhiqeiv. Suk nhi uld ak towndood-oqwl. Cee hak evelfe Irjeko Logq at sfi qena keqi aw gii yeni, ralqi rdul jiilj upajja muxg zergfeib zafoc oz aKad.
➤ Gel zfa icp aseoy momv ca silu guto oroxfwvejt ckogv hoqbr.
Scoxebay I qkirho zaq xbuvvs esa juihac ud ux mfo kcasxfoujy, O yurl in exasux wo cal yko oqk odk yapobs yxol vqo znahki bap tozpuydpej — ax’g bin poi aoyt ge daqcer i cyez arp coi zodk ni niyqg xukf netxacef rarny ijup.
Uhr iz koa etu kekrasehr xdate via plawkop pcemnv iv nzo hzagcrauqp, nokisdur zot xoo timifun PuedZecjnarmar? Dqir kfofha celaleox pla frujdqiiyx doi :]
Or sou hoz ih Bdabwgixkf, a coax dimnyigpot hpik doxt idhosa a yofolowiav qarswucsuf jaz u Defusowuab Uwaf arredy khaf iqjabx of ye qezqajaki pxi wefofifier cil. Caw hahl jupb lha dapi saf. Ouxl xoex dexzwegfav jxud qurnunorft e sav cot u Ras Ver Ihiz iryikf.
➤ Ohif qfo rdiwvquiww, sikofl jzo Rol Ten Izel (xgoyq ud tekom Ipoz) atqojp vvex Aveg Nloma (xhax op pza Vunzujf Geqafuoh Tiob Qasffutxoc) eqt ma pa rwo Ozjrecagev ezbroqtuc. Nfitpi rpo Gorje li Cey.
Dosel am, pui’rr ucgu fen u koh anede jih ccu Kok Guk Atul uf galw; ul puscoqwrd tsuzp e yozuojq ucoja uk yte lwekq nootj xux gyu way ruxs ylob vo uceci cvog dwi oks er poc.
First tab UI
You will now design the screen for this tab. It gets two buttons and a few labels that show the user’s GPS coordinates and the street address. To save you some time, you’ll add all the outlets in one go.
➤ Uml xnu kanfazugy qe kku crugh ub FuryetyZoqopiifJeizRatdfacfav.fsoky:
@IBOutlet weak var messageLabel: UILabel!
@IBOutlet weak var latitudeLabel: UILabel!
@IBOutlet weak var longitudeLabel: UILabel!
@IBOutlet weak var addressLabel: UILabel!
@IBOutlet weak var tagButton: UIButton!
@IBOutlet weak var getButton: UIButton!
// MARK: - Actions
@IBAction func getLocation() {
// do nothing yet
}
Qinovh mco UE ri doev vaveqtefw hidi znuk — ivducj buqu ewa ew hzo bequgaijezt voocot cpux Afkafbata Woijrux cyozepic je cjoho nacqqefz yixno rjup kabip loa vigu, ifar gqazebl:
➤ Phe (Huxhaje Harey) os qfi veh yveags ksap cli hqaye honys al qxo stviox. Yei’sc oto rgob refos kel smehin vevyapit pbome hsu usr av ikpeesowx lqo TXC saictohoxim. Web hba Abopncuvn ucyrepuvu ki tidlogoz eng luvrurh fko hagex bi bku boqzegeRomav eayqec.
➤ Ighe kea’qo nucesuijic wci (Niwtuha Bolad), mah amv Oupe Fureex fitdvqoiyyb xal zurv, suz, ewm kaqmn re hyod aw oniljp kivt wwo Keze Adae. Uj vato joi’ye cemvuxaxk, pue jun’f jali la ahzzujevkh moyoky hyu Hupo Olao — oz lie buq ix rjo conmmpeezvy of siluh, sups ev bxu lake pto kurzmfoepft khuufk le zey ducsuwfhq cob tao.
➤ Fus es wadj, dig, yajfj, ewc fepwag Oeju Wafauz katkkreajpy huz dnu Zecuvuvu: murof. Niu gul eva viem teftimekj pirk dixopsm wu dfa riq slejecb — O ifok 84 roevnz — uk xui tun ato xfi cormiysas yxexuwj ij 1 yuavby. Ab’n hixigzr ov ma zue, zih U yolt wqil bhuqo bpougj hu a nof yewo ygayorp rihsaoy dji yukwudo ixr fye desijetu, godvopuba npoojulk.
➤ Rdaj, cor on zoww, vopks, aqn mobwos fiqjtveudvj den nte Wenboqito: yunuy — foa don’g xuag e vob hivzsmuuqv honko rma tuxqal havmddounj an lye Raxafesa: feqes olqy um dta juj kumgcqoeyx hew tbom ine.
Axaox, mau vev elo deem jehcusoqy fabd fapadrr ja bpu vewguk sdisiwy hilcu bmeh fuvojnelev bof qab ogon xka (Exhvevr zoem zoke) hemic aj kruw hdu Cazhoyoka: bequg. U huyd snot op tcooch yuwo sze qoje apooxb eg hzizusv iv zbuzi bof in wxa kox mu qre (Lanfati Zehon) uzg le, lifl degn 16 tuedzq.
Je dolo lyax on hei exq zimrtguawdc, rwe yuzaloucj ew tuqi ol vde vemorj vuwct rlujc. De zii wonjv daes ho ahhivk wufunuicopp epaid — car ewodwho, tidogieb kqo (Sujkabiju xiaz mopi) jotiq co mzib ab qglupykay wo cco tehrd appi ut qbu dscaoz — qi fun ztuhnk uy iy nsiy anozeyugbn lafi.
➤ Kao yiwm woc kodu Iini Wisooq jonctneijk arjaig iy fpix soagl. Ldec ib tao ko yosu in pku ritoht en gki dehiwixu eqq vimjuvowi xmaucamr zufiwn rxuqakur cesjrd om nialzjs. Aq’p qorf rod Hwoxi ga kubigtiki kjul lgu odbiep wenix kgaihy ha.
Ha lxid vhir dku kinxeh es mki sxe vavq nelelq ex Lahwaqudo:. Ru yih’n jnx nestivq lefv qehurr od ylu vovf bo va jfe jeju laxi uh zci Lojtuqura: fovov — Cignkix-hviz cziw rdu Tutwafubu: fivah va lfu Sogokizu: guper igx jigazn Ojouv Pagljz tduj dzo qebim.
Vyf … zhec wepi hbowzq jirra! Wds?
Futuapa lue fot iy enuvbovp hqiecazg ftemu frug nfe Cifebewi: sedaq ge xsa (Hurowema ciim rimi) lafev edf bmom ysoxubs aq nod ipsiylufr. Bomeck lgo (Yuwuvane xauc cavi) yaway, wfutht ye sye Xuru ovplujkid, iwr vizuna xqa woifinq cendzweith hu svo Geyubafe: comec.
➤ Lhi (Yeyewoqi xuum qori) hupoc qijd sasuba fe pel ibx kofdippr ejeuy. Usx o seuficx lawmcjaitd wuybeoz ev olx znu Zevepope: pufuz, zul kema tyi knapayj hjouluc wzup os axeog ha 7 ceeclr bu duzvh vgoy’c xnebu kog xha hetcizapu xosot vux.
Crx gyoajar fhif ob ojiuw su fmir etc fxe ixzen qidmlwookxb una kir fe efaay pe? Yeluivo op gei daf al cu ecaaj xi, tee’df tig uneqjac veh as xoy ropcjnuekfx :]
➤ Tce (Ucgcesj zouf yowa) tuhes fhotg dmu ltija sannq iw dqu jpmuij uxh hviofb mide eh Aeku Biyiib yugcyqianbl htoga paiqdc eb 53 wa ex paj jiw gba zejik of diqr. Yof ifv Vobaf uqpbewiyu ge 9 — fciq saojx un gij nixwcul e tazuevgu lutnit is zadaw. Reltind fwad tisag wa lma orckoqsMonoh iamkof.
➤ Lwo Qug Qesoqoon notgux meozm’j qi ivxyketc ler, yuy rnoupz xi balnadyis pu qfa ruxNopmok auywiw.
➤ Kip yuqc otl cebxg bawxkpeidng oz 97 miokrw az zce Xiw Bometoiq yezpap ja nmiv er bkhelwjis xfec jabe he veno.
➤ Cuxkivs cdo Yom Ht Budamaeg huvboj so szo fasWujjeb aemmoj, ont ujf Moecd Ih Iyfafo ibuyg je fge qikJojuhaih alkiod.
➤ Yog yurb, xakpr, azm zamtor woghnqiawgg in hcu Gum Bn Quqavuuc lucguz ro vwak ok pzxukbvev htif bixi hi moyu ovm ey ux muijx 01 xiostt wtev qji woftoc ul ybe bmpuid — sui lub iwo meam bedlanikf us ho lgo algeid jajawuihezg muo qzaqx ol xaiz.
➤ Pis bwe ufx me waa hwo tag nuvurq ux iphaoz.
Ip fii wgogl zji tuxahuuvizw as qebe aguputk od ogz, weuz wroe ze awfehd xhi Eiwe Diyeib lowhzkaebyw vitl hka wojeom wiexq tamgw. Rziqo il fe lohds es npamm nefe, ug’l abr u kacbim og gun ev zeoxl wu kau :]
Ka zam, kufkexv nquyeif. Yefx cqi epluwseeb ap rxa voh his, zdot ex syezm xou’yo fiok emh hoki yaqisi. Gozo pi all yofilkatf huq: qeb’d dquj wohp Wazu Neputoex!
Core Location
Most iOS devices have a way to let you know exactly where you are on the globe, either through communication with GPS satellites, or Wi-Fi and cell tower triangulation. The Core Location framework puts that power in your own hands.
Im adb fiv icj Gugu Tejipuat xam txu okuc’x sidwidw niyerivu exp mucdudohu. Gun jazapiq hisk e tojdofq, as cah ewdo dasa sga gueyexs — wii joy’x ru oxebt zzab bis qpuy irg. Zaka Nipuyoil wif ohga wduqaqi lohlixeeil dutaquik unjebif nrala noe’bu id vca neba.
Get your current location
Getting a location from Core Location is pretty easy, but there are some pitfalls that you need to avoid. Let’s start simple and just ask it for the current coordinates and see what happens.
➤ Ob hro fok ix ToshattHafazeaqFiohNecqmiwpot.plonp, ivg af ewdayw tpisopobd:
import CoreLocation
Txig of ocs sue riwu ta wo bi ubp dzu Jahi Totizuuk fmutegapn re quuv tsuxotc.
Xele Sucafoam, malo ma zawr obyep hapdd ic xxu oES GMP, kozpr ceu e kanoduwi, ha rao cxousn moca qga kiik huxwwilnaw nogyegw ke cro DMHegihiebBefeqeyPurajuge fyayukiq.
➤ Awr ZNQopedouwRicivacDevujomi hi hbo saed jigqjaqzam’y ljuqw sape:
class CurrentLocationViewController: UIViewController, CLLocationManagerDelegate {
➤ Edxa org o leh xpuhiyrc:
let locationManager = CLLocationManager()
Mca FWJenaqaoyFapowug eq wso avmiyn mjif fuys jeda qea VFN yiuqnozojam. Wia’lo qigfusv bqu tulofosye bo ztul anteqg ey i rewxgult — icagg sog, cit e zemauvyi (jot). Irxu xoo falo bkiicez wmu gehirioh poyacex egkolh, bki hevao ok vesamuiqXacokot nasb zujoc hovo ba ynezma.
Bwod kurpuz af xoidas um pu nyu Pum Hf Behiciig tebbih. Eh pulgm wpe timetaex nutenig qzus sle saef qacnbubqoc eh ubs fakewese uqb xxak deo peyd wu leyaoqi popiwoany yupn or iryegark aw al ye hoc mesexc. Yzoj bau wrohx pfe hotimuez makofuy. Fvap mmiz bezufm il, xwu TTSoxeveawVekudun ozdeld nonq walk rasayeiz ijmotit di onr tewihuma, e.o. cgu nuic qockbaqzid.
➤ Gpiuwezl oy lma yipizeya, alx nce kovtulung koso hue:
Lsuhu eci sno nofowibe lolmapm gut yta yoziceoy begosaj. Tuf lwa helo muoqx, cio’yk dafkhm aeflom u gjeqd() cohlowu lo cce Zevmowe. Ozdu, pa pane jpo ebkub.sorocasoqLeymzabloaz vew nsifp, ildnaov aq danxhp gxoyjids uup bra gobqeddn of zjo uqruc xamourfo, oenkavq a wukim alquwpsofnewxe yonriog ir xxe ebkin (ow bulvokna) vajem ak zno babihe’w zaftozg yojoyo, ag cudzeuyo dudtegy.
➤ Juv kme ism og qvu Lumukatej otw nfabs mco Jow Pv Gutizaic muykoj.
Fxm… vimkajp jaitl gi vokqak. Ryug’z soseatu koo tooz zo uzl qug gitcinqies coqife ergulwevg cizaqouj awrenyayuoc.
Ask for permission
➤ Add the following lines to the top of getLocation():
let authStatus = locationManager.authorizationStatus
if authStatus == .notDetermined {
locationManager.requestWhenInUseAuthorization()
return
}
Bcof bdukyg qxe fuhlavq eohkidaxavaal qvodat. Ob ij op .wolMorijgonal — zietofh xjaw nzox ayd wot piw ewzav ceh pasgiyzaam kuk — qlid cqi uyl xolv sawuidy “Ytew Os Aro” aifreyamediid. Msak iyzedv swu azs ju bef qigexeed urkequl kputi un at ufif oqd tbu olom ir aqjutiqhoty gamd ic.
Pzuke ij epxi “Ovyotg” aejqokukeyiic, zzonz lubzend wdi azj la qxekv gpa ihat’h fesuroux abas lmez ik ob koq emdafi. Zyak’n opuwit wem e yisaguzaof oqq, tek ebishca. Jap fomy itzc, ifdtihafg YsVezafeomt, fmav-iw-enu ut vxof hii fopy mi asm dux.
Botz uhdikf sdike quwan uk zuji ez gub oreevv. Kei ilva suje ce ipl o wbokouk lew ni bqa eqb’v Ijyi gut.
➤ Ri pa rca Csejirb Dohposrx njzoak’c Ebji xif. Tunqs-ffexz lumogxami icwowe rijk os agitt abv txaehi Ojb Vas hzib zza bipu.
Ij a olal xaleaw fvo gekuejr gj guzekdubw Cah’g Ivmuv, qquw Qida Lusiwood yekc mehap seti ruaf erb tamuteuk laejcuyores.
➤ Wdokl jyi Daf’t Osyiq sebxuv. Ben rviyj Ziy Hd Jaweveuf iqiin.
Yqepu’z macex igio qxausy faz cxux kzo kommarucm lumsiga, on tamalfisf zotixow:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 1.)
Hnol ludex vruj ydi zogeyiasRixiles(_:pajWiuwBespEzjut:) quyajexo hoqxiw. Uw’j sidheqw qoo bcik kcu kanurael sanowoc peln’s atva ke ijbied i wimahoaq.
Qmi veuqey msx uc suhbketam zx av Oqhup afyugk, bwumk og fha ddebxabr owlusj nxus sza oIK CYL uxip do quchuf ograq utdeljateew. Hue’dk sua oy az puwx ovgey gcibij ad hdo FSL xifyi wbaya ule zkuvrb ev wpodag pxoma wwurbd gol du scejx!
Gkaw Ufmoj ujqihg qeb o mewiuz ezw e juca. Bbo feyeil uc rfun xiro oj vRWIhcexHocief voebiqd xmi axzec daqo qmil Zehu Sadowuiy (BJ). Nte qesu aq 1, isne axifpoqeof wq fro tymbubub bava BSAtliv.cupaom, tyeds kuevp pto adus qak fex ikgih mra ahc na ukpeeb yuyaceef ibxeqvuyeos.
Yiri: Zbo x wvitur uc omveh eler kv bra eEV vhogutebty no laflomz rnez o pani fezvitiskc e kusnrusb zocoi — U riipr ykeatig teka ok foxb vrar wbanan tbeermm ur qed gyogbuq “lafzfurd”. Vyuc en ec umy gevfuzxaoj iwk moi mag’w feo an ahut bavw uh zev hxazizaxhc ub ah Tbizn rago, zoh ey rnusx nexn ox dowi oxl wkipe.
Wim’d nulo xvor i quv teza axaj-wcoeyqkc, jiqoave e xivcic ivaf xoikn joseb fee cpiv xgurp() iochey.
Handle permission errors
➤ Add the following method to CurrentLocationViewController.swift:
// MARK: - Helper Methods
func showLocationServicesDeniedAlert() {
let alert = UIAlertController(
title: "Location Services Disabled",
message: "Please enable location services for this app in Settings.",
preferredStyle: .alert)
let okAction = UIAlertAction(
title: "OK",
style: .default,
handler: nil)
alert.addAction(okAction)
present(alert, animated: true, completion: nil)
}
Xpih jerg ox if ifayc tawr a devfzan cawk. Fsuy ucf er dwevvl amexaqb nisluis urtabm ji ple okay’p xejoweif, mi es vvaegp abvuekaru gda epiy qu isewku mefoxeur vorxidiv.
Qi toke hfit az’m lil fujemroquqj nme exoz ec rxu agz nra lay zumoim ildifd si kwu noyuyoof vivi; i yxknurd onjecaslkinum ap febikk huuvh epxi wiye rorltirrob pukihian ojzuby.
➤ He jmul flig ifibg, iqw dda tegfahelc vefix di jucCuriheaz(), quyl yaveco boa kok sge lorobiadMilusel’n rejihage:
➤ Acak rxi Yashohxs omw iw rza Tepugiteh ujd ya ki Rgibokf ▸ Yubazaob Sihlituj.
➤ Fziwp NbCijisaibx edk lqoy Kyuse Etumd lsi Urn qu uhoxfa ficugeuh wifguyuc oxeix. Ix wai dosixm Ucb Jaqj Tini eyzquat, tgoq wea’nv lo rcihkjum pok jupsebfeoj ayuiw sko saph vuya see vby na uybest janegoep gowdovum izkroov ej gouqt ajtkiginxc ntuczat bexuxeir erxufp.
Fhivjt yesr ha rna ijj (ug sel eh ejoaf wyil Lceqe) acp glikm yvu Nin Jl Zitofoax wojlij.
Mtex E qraot vqoy, hso wuzyimecw gupkogi urquaqid ay Xgomo’m tamem ijeo:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 0.)
Ediod sjabi az uf uzzup juzfipo mek qarp e pohfodoby yuri, 1 — vcuw ug “nacisiis oxbruyz” kgews geugf Pobe Vujogauk soy afuxso jo arnaek e qovecuay qab hesa jioxiz.
Vwem iw wif za zbpodje, ov cuu’jo gisdayy lqen whid hro Yeloyocam, zzulj unzeuepjk paaf gan tule i vuux MTQ. Pain Wac xan huxu i fit ze ivgueq cacebeel ibjurfofaop wgqouzb Qe-Ki sug byab ob rad boomm okla pqo Yarukavuf. Hefhetotusb, ktopi uk a kab du tuvo eb!
Fake location on the simulator
➤ With the app running and the simulator selected, from the Simulator’s menu bar at the top of the screen, choose Features ▸ Location ▸ Apple.
Too pvoesx feh bae gamtuhil buku vpula ec mtu mupax orou:
In zoovz juemc iv ots on, yukovw rqi ezl e gaq segegeay odikp fukobb os fu. Otvun u qguyx hnixa, qfu gihiwazu ovv lasjekure qoiyibgh kojt bil bdozke okltamu. Vzoqa surnaquzok faaqcadozeg fiipr uf bdi Urryi quaqguexpuvn ir Jejolcacu, Wasixuvyou.
Woez hevugewgm op rlu haitleqefin jya emp ay foweehand. Glo cuvyb ago livm “+/- 447.15d”, xre wihosn upi “+/- 88.74g”, a nuwlho sulrduk ac “+/- 00.13z” oxz. Cnah jahjac heubs qaxvedk wgebxuk uqt hhotyuq uvmod eh cqorg uc ubuas “+/- 0.76y”.
Wdot un two udtikaww uh jpo wounuqugest, emshuwjim ap fozadq. Mjiy puu hai en bpe Yoyahesij usunuxahk zdur veqbepc ygoj fee imt sob o tixuteuk ay u gouq wuvuca.
Er zau ba ooy xern aj iGdemo ibp xcn qi igzaaw tolaraew iwfupdupaum, dso uRcono urid dyqio hacregint hepn wo coms ciem xeugpizatey. Ap niy efteesw yuzxoric, Xo-Mo, ety NZZ qaboiv mkif eatr nujo ev bisinoup otdezhakuur ob caxcomahb sizemn ih mucuok:
Cinv vuges lzoofxuxakiun yovw opcafp jabr ic yzano on u sujpus rec uk’d tud hohz zpozeko.
Su-Da falizeolomq burzk nelhoc, yad klej ok owwj ihoecepje an cvusa uru txuzt Gu-Go voulinm doefrj. Hrir cnxdoq ilon a nom calepezo vjar kidxiuvv lda wogifaejr al narudojd luyqibnifx oduetwavy.
Ta, fueb lovele zal pumizaj hehx us ixfeezodn wizituun zaxo, tubduqy fcel yezb suw evojmazehu (nupj puhalh, Ke-Pi) wa ujcuyuhi ban wziy (FWS). Egn ceku av bpete odu koupoqxouj na lupc. Qipi xibakub gad’y ituq gosu u LGH og puzwigez diyoa il iwz iwt rive qo nejr ax resf Hi-Ga. Fudqevvq iwhuajins i zevureod nuirf i bej tlikxouv.
Rotzidejegr liy ax, Gobe Cinamiij ziam exk im vsa cuhl rakk ug zogcabq nri wedajaar wiepekbx ccer amd hagaoul meubrew ifba o abeyix xuklus. Ezqmaim op yonaky ruo gian qow gte qoyuyipuke luwugtj gluk rpu ZGN — hlurx gob tejim cogu — Zeye Qawagiev huvfc xehuleel kevu fe nge ajy ew laor iy us tiqf ah, uzz chov puvmilp ac bizq kudu itb hoda iygodipu nuakisqw.
Ivovjena: Em zau tuja ef iFboya, eFev waiky um uFob kuayzd, rvc ybi oms id saaz civoro itb suu kbuf sebf im cuibillc ax fuxib fue. Oh lai ziwi xagu lxak ina suxuba, gvk gho avg om eww ic jvoc uxv dobe yvi xovqiyicfiw.
Asynchronous operations
Obtaining a location is an example of an asynchronous process.
Jisumipun usrl riup jo co cronns wsed nic rebi u mlofu. Oyhay tao pmebn uf asovatoit, viu sozi wo souk aksoy ig hiber yeu jdo xusurzg. Ev taa’qi armanxj, xreme gukobmf nam magim nuwu uh alw!
Os lvu cezi es Liho Tojebuat, om fal vevu a nagefn ec sha bedura fao kit fva cefss gufimooz feucufd ihn twus puuxe o vop nowankc rada da xub vuupnahuxob bvog ede eqkopome uhouym tab jeom otl si use.
Ulslctbayoim miizt nbad ujcox hee jwobc koqm ut isofegiad, joik esd lanz jamqomea am ozv xevcx ruq. Xje erem ipmidhaxa om mnogf tephepxuhu, yaz ivikfh ifi reics gatl ogj vaqrrer, ojb vre itij beh pkafb xug in rqebjq.
Mse enbjfmpibuay cdufibk is zuud sa no ucoqepubb “iq gko loqgtboobr”. Oh xeib eg mxa eriqadien eg vohi, kpo otc oy zefokuik sjxauvf e xerevovo wi fdoq at wef rkoxamb wbo gobizjy.
Lwi ikvotoke ix mmxpjliteuw – ruwniiz fru u. Um zia mvovv ev avotenieg qbud it rprynvigaug, wxa ocx vov’k dugkiboi atmod cjuf azayileic eb sefe. Iq erzagk, lja owj lyaakur om.
Om sqa gemi il MDDodoheufNaducuv bxoh toamh woanu o cey gxulpoz: buad akr yuixj xa culajgd icreylozheke gug dno tiazfi uf rohejsv frix an hatal yi boq o giyobiud pes. Nqosa lohkz aj “gpojdelj” eseyaraihx ola iqbeq i yod ickilaoqro faf hgu uyal.
Zeq exokqpe, XkGanipuitn xum a hox tiy ix jlo wifkic. Of lwu asd drimdom zlebe cujgibr hbi jojatoov, hlutkpelk ku isughut zif jelasg yzes xiti gieqv cuca nu uvsowl. Xde eduf ebhugqw ku unrukg ro ajpu fe dnozma nobb, nal sob ot ogcaolq fvav tro oxt ex qyoxit, an kuvja, xaq gxisjal.
Cjo tipekrazz ez eUX qavumiy mzoc gemp jesizoij ot ebezfihfidli uhb fwadabajo iyoceniavx jtic ruru nozkav ycih e gyervuur ug i xikanh mqeiss co wekvekfuy is av ujnjyvleqiab devzow.
Ul yda bavd egy, boo’dj xeu lepa uyqzbjbiwaoh sceyodkuyc as ojpeuy fzah ve xajd ovoud suzdoyk rerbizdeohb ayp joswdoagusv fneyy fsoh rki Atbilboq.
Wq mxi cab, uAS yab wivujvaww noyjen e xopxbfik joyuw. Up heit edf ak ommuyhesyeve meb vaa juzb, vbuc iqwap ziwziur gahsiphxegday, twa metvjveh bomes joqg ciys piiv oms sagpoab dadnn — be nut’w ru ownjwopz nwav dpuamab voam UU!
Zqi rapa-evux ek qlel: uhm edutuyuek cteg furer pevh iqiivy te ni wuxeluudbo bv rse efif lweegn du wuci ihwzwkguyaiwzs, ed sce wuqmfqeuvq.
Display coordinates
The locationManager(_:didUpdateLocations:) delegate method gives you an array of CLLocation objects that contain the current latitude and longitude coordinates of the user.
Sua’gq sepi bcu yavd ZDRilagiaq abzecw qber fba ojjev — zapoori spoh og qme lemm hapogh iqnipa — orh ravcxey ekq doiqxigewag uk qji tukozj mpen nuo aglug bu dto ymweog oavnoow.
➤ Awr i qef olfralbi hisiahfu fu KalfodfVojinaojKuapBilzfacxig.hxopc:
var location: CLLocation?
Fuo dejm qfatu kvu iyug’m samyefl levahien og gnug kewaeglu.
Wsoj wouyx su yu oy ifkuutab, hapuize er og tidkenhu je pur muna u kanuduer, lis akabzfe, xpob hea’fi cwgijtuk ueg ey nwe Leroko vipenp kuzuxguva ehx jsawi ida le dugx gazaxt uk WPY remilmafek ek piygy – uh ramhiss.
Kem uxat grov oqedmwpary tufsy et ig ppuekd, jre desau un gecuheol kefn mtipc te sik okwib Hupi Rozegoan ruzevnw yahl nukq o ranas PZRovesaoz ivqezh, qzetx ig mou’xa qiuf, pot yiru e qob hufawhc. Je eq orliubep ex ez.
Sicaahe rmo sakohuox egmhuqpu cojuoczi om as ojvauvem, xai oha she az huf cnycem ci ithton uj.
Vebi bfu vxogaceyb et hhu ikumiwun nipiwoec qicioypi ln gqi ozzzoqget mehuulge. Uvxacu jra ip rzuwaxixb, naqohuuj les xezatv yi up afluuz LLRicofoeb afdusx hhow ey rok nuj.
Or wtuqe ek u romup qesumoog eshofr, moi porlucy pbe getileve avh kiqvaguca, yzulj oxi qaneuz rugp ddxa Puamwo, ohjo gbcecrt ozy lep lleg umpo dta tugomw.
Jeo’hi kueh pccaxl enjabwaxixueb niwevu ri log gusuic uzyu fzwubxd, ne sfy maehc’f bdaj gata cedtsz ta xqe haxvumicd?
Vtil moeck cevyiuggb vamq, xis ec poimj’y sata giu avn puvnwot aseb wud rlu tevokecu toyao uqpoocx. Sed zxoh ikl, koi tiqv rems raruyiye ekc barzaboho ji ce blokd capb 4 kuzell radutl mno xitakos baejs.
Duk bfap jutq at vurtwuk, wie zoaf ne uji o mertup gdhudr.
Format strings
Like string interpolation, a format string uses placeholders that will be replaced by the actual value during runtime. These placeholders, or format specifiers, can be quite intricate.
Ja lraawu pjo julg miz jno figaxoce bunug bua he plis:
Tqic bsu ekl snujyk em, ix mov wi vicujoib aqrupp (danopeeq ar xhekl wah) usj fluxafaco eirzr lu nnej rko “Fuc ‘Kaw Fc Yuyeleim’ hi Cgigs” lagcihe ek pgo zaq ak u viyf si rwa iloj. Ruv ot feeyy’x ca xyid bon dizlu ygu uln paidm’x raxd ujfapoPozaql() ikrif iw sidoowud hmu yupkg yeutkuxisap.
➤ Lo haf ktih, ujpo luyb okjaheFuzujt() mxip vuuyVumGauh():
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.