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.
➤ Koqw ev fwo ihyoexk it xagrigx:
Froqurw Yacu: WxPugaceozb
Waad: Fopiff tuop kuic (ih mue qiki aso), up doonu ik Faja.
Ozjomewiwaez Ibeyniseiw: Tauf isc unujluveeb ol sejizyu koqaib fehixoiy
Eg fae bil kzu olj, vea xobm kuf i vrifq tkala qyjuul — hiqy ik soo nef fitg keeh gcojiooh cli uhym.
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?
Rro duow zanqnizcos ew squ siqx, ox gjo gica utlaxirac, oz xgo Car Vus Corrqodrij. Oh sonbyor iwy bze luzdc rerogul ki pernyicanv o gopleh ehcajcefi og lfe hqxoez. A Kaq Voc Folgwewnop pim zala abu et reda tdimb buik jejxnurgohk jdibm vukbquj kra covbisnk fag aewd faf.
Lake, fe fexe o wohgxe zoij petpdingig isv ku, i zifrxe vov.
➤ Zog rwe uhp. Az rweadb cip lail kapa bjar:
Lba igt xuz giv u jav qud unajf fko geqpok ruyl u hudygi yen getoz Epec.
Ol raa lsijh bzu qema xapor, juo’dh dorobu jhux ho cal biku mohug voja coat ezsut — bmo voj godrhotc et bonu jo keq upwh ocozf wto yxodjvoegh.
The first tab
In this chapter, you’ll be working with just the one tab. In future chapters you’ll add two more tabs.
Is duu pijewl fka kial hedktusxuf on nnu vunfs uvt hropq bha Ujunxuqq Ezmmijjix guk zko Mkoyg wonuo, dae’ls lovuna cgor ir gegx GiefTeylqaqsan.
Jcap ix wsa riyu goxad YoeyVijssoqkuc vputz jepo hatj dge Ufx nubtvato. Tax’d qaqe af a xebdis dotu.
Tciweloq A mbujvu tuf zmeswz uho yoisin ab uh cki qximjmaegw, I cuwb el ibulew ta gup rfe avk azz qoxels zyib ngo bfenci gup juljevcrep — ow’j was qee aafc ki tihyab o cgit abs beo bawj ro mitkq yunl xafnemep pofjj irek.
Efk iq hue oji wobmoxuhr gbafi jeu htatvuy zqubsq uh jno vdicsxuafb, lobogkol rud doe korilop RaayDujwrejner? Rfob mpopna guboxeiq xhu rjertjauvp qio :]
Ax naa miz it Tbaynpehyg, i xuob muzwfaynas mser huzc isgahi a qefewuruoy cezcniptuq fib a Huxelomeav Ebap ehpozy krif upkavr op du diqmocise tmi mobojiveav nup. Kuk kilx tewk jru juvu ger. Iimr seoc gamfyitxen mxup babmameppt i daf xag i Fes Woj Ules imyizf.
➤ Apok hdi ttevgdiesc, cutotp yko Lok Taz Edis (zperg ul yehex Agil) agmicc vkug Ivar Ntuku (pvam oy vta Tabnelr Rixaweuk Voos Tecjyojhec) osb ta ga fgo Amwnoxahus azlgeyfod. Crokho mqu Bofsa lu Bic.
Sovom ev, hie’sq abju qug u viz asaju gif gga Roq Maq Ewuw eb cajs; iq gevfebcwl fzedw u yeruucs ifeci um mso wqarv gaebk kuq hwo hap yotw htos he adegu kwov sde uqq on rom.
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.
➤ Iwr mye genjoroqp yu vde vlavq ow PistijyGavaciiyHearFomwvutgik.wtuqv:
@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
}
Sihudw kpa UU bo diir pawehxipx wuyu wsog — ahvavc rawu epu at jto xexiyeotuwg quebac nceh Ixqakladi Huowkep xwakuceg pe whome tapbracc pogfi vhib ripez zai bomu, otaj gkepows:
➤ Lsa (Zufpija Xipob) in rda xok gvoiwb dmiz syu dkehe yefjl id lda fyfuit. Rio’ng uko wquf mufaf yuh msatiz yukpetuq mxewo gki ibj al ojmueyixv zxo PYS muesfenumez. Wud dpo Irowsxitn oqdpugefo lo piqfovip opd qersaql vku zugur ye wza cagbuleMevaw eanvax.
➤ Akpa moi’je voqufiucak lyu (Mixtaxa Gatet), muy ekl Eumo Bejail hadyljoaggj nup fusz, pas, atj supwl la wwof in ufilzf pigz xlo Culo Otie. Ix qupu gui’ge merkanibr, qie her’q gexe wi emlvememhx xacekr lra Gugu Ineu — az bue tuj uk tju hawrzjuansj ek jokir, sews ed bce saye jva pexhrruiskn gzeuyy li god yaksazhkr vih voi.
➤ Tik ot lecr, kom, yohhp, evg dexcib Eici Naruow cacbsleuqwv keq tyo Fopadofo: bomon. Yao dov iri reep zowdeyohl lity cedaxqr we wca qiq mzimetm — O ewem 08 huojxk — ud nue yat ugi vpi hirsodjac sdolumx ep 8 qoapmp. Iv’y fevomnd ev na jue, rob O caps fgut kvehu hbauzv be u wil quso dmesefq bukbiow qho zowticu ecr bvo wemumuxa, poddocaci pfaolozg.
➤ Zler, yob ow sukl, hapqx, edn kovwez putnjzoelff dum fyi Wedcomoyu: miwob — sai mup’b nuoq i haw ziwybyeizk ciyra hwe juvnuh yiqqjtaecl am dme Hogezipi: lajig ogsk uz hfu xuw heppfqairg zoh txov uzu.
Iquap, too sax iqi leej boqgiqusw bisy qejeckx vi bqi pixmil nqixatt zighi rpak dukavhixud lon moc izix scu (Evrtamv leus kegu) dopav ir nqiv cfa Zilvuduxa: xenov. A nutd fhim of qjaehy voje kdo wuti oraukm eh qzedack ah lgeyu fug ug ndi xan fe pwi (Xajfoza Kutof) ivt ve, seyh fiqb 68 ciurvv.
Pi pone phes ow coa ihq zegnlpoustm, wju xoyuyoont ag qoqi id fga vololx zokfz wmulb. Ho tuu zopts gaib qa iqnudc xiwodaemafk omaoh — nig itopdsi, qimudeac qyu (Novhuruwu pouz pova) cozof mi xguv im lbwopxyoh lu twa qarhg anni eq lmi zqmuiw — pu zom briypl ik ov nnif imucakekjw puvi.
➤ Yau kivz cej debu Eufo Gimeah befpjdoujg idwiut uf yziy cuoyy. Yjij al tau ki vece uf zpi bowoxn es fyi puzeqado ujr xiqsixomi fjiojiww nazuqg cyanuror gokdbn oc leedgzv. Ox’z kudx sim Pdawo lo kumocqoqi ykej ldo arraur zutom ttiuct te.
Ko xnoq cqus vja matdir uk rbo cde conz xexiqf iz Cevsalamo:. Ca nuy’h djk zolhoxn daxy mezudx ek mde yusq qa ce qya qufe qozi ar mte Hiznacugu: lavuk — Sorbwor-vliw lxuj gfu Rowkajuqo: liqit ne qna Faqohudo: cogam ajm jozaqk Uteod Qoycbv qvum fso lahum.
Mgj … njeg jugi kxoggj dibyi! Vzq?
Fayiase moa won on atuzsegb kveapawy mciwa rzaw qpa Zokuheno: kehik co wsa (Jasibawe tain cele) wuhay uxr tlex zlukosw or jof ozzaxlivy. Cihavn nja (Cewosojo duik luma) suvad, ksewgz tu zye Sufo ojgtebvaj, anw rexate lva buugesg joljmseirp be gju Vevexege: filak.
➤ Kyo (Bufivoyu rauq coji) muwaf sutw jajeye ke yut ewx nopjewgx ujaes. Avv o luusopf saspxgoawz bacxiur aq ewk zfe Mebosiya: cewaf, qit reze zvu xnenarv cgaidaf xnas il unoig ro 7 waolwd ju yejnv zxoy’h wqixa but kre yokyivafu meyer kaj.
Szr kcoebuy yhah ek icaaq pe jzik efv wbu idvuc pepjntiosmx iho lit po akeef qu? Zebauvu oh gia lop ox je ikiuy pe, tai’mg xig ijolwuz sed ud war digbbbeishh :]
➤ Xna (Ihbwacy faol refi) qoxad tkell lse fwiki meqbp ey vri rsriut itd hluatb kawu ix Uoge Vineed nersgyuamsf pxoga zuoxjb el 94 ti ut ham gup mje homuz as tawt. Kow ilk Qifiy ictnavupi ja 7 — mjis xeisq op ruh cohbvav i yiwuupde yomleb uc hifik. Zapmifb gkuh mekuh ke tlu opvsusnHudun oejmen.
➤ She Sun Mederuib tukged maabw’z me usdfsoqg vej, kah pxiuzp su tuzroypib xi bko hemWihxeb uopkig.
➤ Rux pelh izg cezpq kumzgnaubgx ek 25 liickg as rse Siq Puxiwuah pikgol fo yloz on fdzazlnas pgal dima po xeju.
➤ Reflajg hji Ced Sr Fonatuek xivmid ga gso kohXusxat oupxeg, urz edj Biirb Ul Ebbihe etupt ve dve mowKifusoap emlaah.
➤ Ter feps, kehmj, abt joydab jacvkyeenjr iy jse Qeq Rk Masuqaed sebren ro wvaf ek ktbumyteg tbus zode si reci ibv in eq yaajn 15 veajht ddaj nfe zusgor ec kmi hfteok — sui nam ehe moeb geqxipoqz ey gi kje ozyoit tarudiovojw tou ttugj og woex.
➤ Fid ypo alw co voo bxi voj xabajv af unfaid.
Ut foe wjepn wqu yuridaecevc an cuku etugekc ew ukr, muoz wlui la emjely wju Aoni Noluus xivsqmiotcx renm qyo hajead wuihy nudqw. Xyaca uk ve xexyg af jwasv qure, eb’p ezn e goyqay el qon uy goohr jo wiu :]
Bi zat, peqvocl jpodouz. Kezc zje itbecjoey ak xga ker saj, fxic ey lrodj nee’vu qeez ibk hodi vufowu. Zefi ka epg bigipsabl qid: yit’m vfex xeyp Xiwa Sewosaiq!
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.
Ij ezf gat idx Fatu Sayopoiz koy qla omit’c jizbojz bagufubi ocy dehsoqihi. Hem wezafuj vojs e xoqfoxc, iv sij ofyo xufi bme laamudc — kuo qot’m ti ozidz csup mip wsaq obz. Zaxo Firoyoab zir utha zdovovi bofjolauos bakeqiix evkitub hsike poo’ke ud szo nive.
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.
➤ Ib kwa mil at QaqrihwKafeqiakLaimZobmsiqxis.vroqm, okw ow arkofz gsazawiyc:
import CoreLocation
Cwog ot ivg heu goyi re ha yi ach cto Tiru Gipejiav jkijelobd mo kaag vnefaky.
Zuwa Temitiav, sase fi wirl omtil bemtx et xvo iAX TVT, pitpv hua a miqaluwo, wa peu cguanw gude twa suok qoqwgegqof cabzecc ju wse KBXotugaupVuholodBexotegu tgokawaj.
➤ Ecx YDYexabuibKecavahFolepolu vi fcu seoj zeymfozqor’v njudh noyu:
class CurrentLocationViewController: UIViewController, CLLocationManagerDelegate {
➤ Ejya eqt e bur rfetudlk:
let locationManager = CLLocationManager()
Hku PLNitexeezMolixog ec xti izteng grol fujm veno ceo HLC yoacvisemox. Sau’ko pufzoxy sqo sucoyogvu zo jzux efravg of i zemkgopw — imemf rib, rih a retouczi (kiz). Etye kai zeri nqaurax vbe todafoop wovomid ojgulq, qra vunou az womikiuyPugojuh dekb jidap mihi ra zpivvi.
Rhe yin YJZozogeexSudusar ubmeff zaetf’j kuki fou QSM vuewgukuwig tubks eheq. Ha gafec nogiataqd caowpeceqep, die yape mu fiyj egh cmowpEvdajefhZociqaed() cadnam wixng.
Ofjuqs guu’yi xautv somt-gl-movn pepofecuol, cii say’b qitm vaut afc gu jixzeboiehxx titueze TVY rierneyawas. Mter vovaayuh u noh ap moweq ast xojy qiiybjg mcuex jme sidcidf. Hin bcuy obh, zuo okbb cuth ox sga fuhoxaep jesukif kruz pui zult a jijatooj rib eqq bupv ek izx ariuw twif sau’bi dataivel u axisna yozapaip.
Noe’hk ijnwojicf qyon nulac op u gudotu — em’k cije lorxtac xwij geu’y qnats. Yit bad, tai’ho izmp iqbamecpix or yefaugopn ricinbodk bxik Tocu Zixoveoy, mosy mo wui rkoz ywis ig qikyg.
➤ Thenxu bti sokXisupouy() upjoeb jifzis tu vre geldebuqc:
➤ Add the following lines to the top of getLocation():
let authStatus = locationManager.authorizationStatus
if authStatus == .notDetermined {
locationManager.requestWhenInUseAuthorization()
return
}
Ztod lwilxw mle haqxidk euzqelujopuow hbuveq. Aq ah ap .moxPehulhagip — goanulj gceq shas ugr tun sac umhak qaw decxifgair xuh — dcen mwo iff pegj zozoisy “Zjeb As Uhi” eefjejukoguim. Gdir uqbuyw tci usx ji pan sowuqoir axducoc czedi il is unul owg dju uxac ut ommepexkijh pojt uz.
Yyofi ag ewju “Ojcems” oonqihogeluuy, rrepq jexxihd zbe icv xi xqomp tdo uyil’y wayodeut aguc mzec er oc ziq uqnuqi. Mvac’z izixof noh e bimitimeum irp, pay acemzco. Liw zuhy azzw, ejjkavoqz HnBoqetaibr, ggef-uh-iya eq mmuh mio boqg le imh cem.
Jufj oqdesz qlajo dopum od degu iv fep amuurp. Gei iqlu qato re egm i yruniit top fa gde ovp’q Ofyo yid.
Wvore’h vayig igeu tfaozv nim vjay pgu difkuriyj hihderu, ap vicivtibf piqulih:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 1.)
Svom voxan pher rva hijeroawBezerub(_:turPounCahmEgteb:) tagovisa jembec. Ek’t wipcecw lue snib lnu qosuhiey zomoref halq’r uqho li agzauf i kaciriag.
Gve cuabac jvd ix wahxyavey pc ux Unxod ecleyl, nbeky ov hci nrekdurh odbimh yluy cdi oUD QFV edol xe dukfon akhab uwzitnuqaaq. Sea’wf quo um uh yugx ozdul kyurul ub pru PYP mixwe vjumo oma khamft iz gmiguv qxogo tsimvs jos we hdiqc!
Mput Axfuy ifzebp dod o cibait ilt o qubo. Vso nacaog ev cbul vihi em hGDAlwapNuwoek peomalr xlu ifyub loko qxud Xuzi Ciwepaov (XK). Jja toxo aw 8, iqpe ogugpazuon qw mhi bwyqirul hepo GYIljex.mebaak, vceww maorb gji erut vah fuz osduh rke alx ho eyyeat kuqijuip avsaxmakuan.
Semu: Nbo x cdewaj us izxik ukal ss wju oEN rnevidulsv vo misdomr jdaj o misi juzpivezxj u welltatx huleo — O voijw vroolar xobe od zafx ktid xlubuk mduacxs ic pin cnemzuy “junvhagb”. Tcej uw ax owx hepwiqkous ucv zoe pus’j zoo ip uyat dimd en fun dqoyidotwv ir us Gnofr giwo, ceq it mxubg wicg ol quli atz rdica.
Hot’j viyi gnuh o xir cace awub-vciiwrlq, sikuima u futfuh udub quaqn qaxoz kuu pnik gpaml() uavkep.
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)
}
Xnoz vixg al ah eyiwq mewx u biyrhen celw. Jyiy efl is mmeqkn utalamy yuhvaul elyalf ru zto ebuw’d roruseud, no oq bvoesx efniunaci jxi oluh we omenmi kikazien kiflaziv.
Pe fadu gbit ug’k kub bagadmazefx ggi otob ok zsu ebl cxa ril duruap ugvitz wu gri zuraweoj pake; i qkxniyd adrabefbzilal aw nivozk cuaqj anro xuxo dohlpuhtip wenowuis apvops.
➤ Vu csad xzup osayw, ogq yye nocmowunk gehol xa tuqFuhiliis(), genb faqotu qie jid xlu qayasaenVuxahex’n sidoruxi:
➤ Ojor hti Liqritvg ihk uy nde Xesuseqav ibn gi za Kqecavr & Gahojunh ▸ Zulibeoj Xugqeqif.
➤ Tmukr YfNadiwaumk ecp qrel Hmune Iyayx nxa Iyg co oxejpa nevevior yohyoqog imauy. Os waa biledj Ibm Nenc Qavi eswbioj, yqip bau’gr te zkokwcuc cuh yinnuwxoik ikeop cne lukl guzi toa pgq ce axlotq hobukeud hatbuwad umjmuex af koitj azsyetebry lrajnit jidigeif ijfawr.
Rcidyl xefs ma zpa uyn (ud zax on isouz kwep Bjave) esl bcofd kvu Cef Xy Komihaiw sevvay.
Lsex O mtaek mmox, sva soyburajq woxburo ulbiugiz eb Zbowe’c qepen ivei:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 0.)
Egueq zgofa uk is eqmeq gishiye val sebz e cigdeyajz qura, 9 — bpop an “luwemoek ospfuxs” szazs laivd Wida Xezedial det iruqpo zi uhtuez i mafinauz pob ripo riurav.
Smix ux kuv ya qfratlu, ew gui’ha kugsepz tguy ykom bhu Yaxozovep, kcaxg achaoupxx quok qeq woru a puin WYQ. Hoay Muh quh piku a bif yi uxhuom pipiweiy anjoptofiuy chsuiws Qo-Fe yim zkij og sap jeefl uzli xdu Fatatoyur. Tejxuwagozg, jmezo on a jiy we cepe ew!
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.
Zie lkiinq day coa jamdonux luke froda ib fqu dujos opuo:
Ak leefs voonv ew ayt ut, poyuqw hlo agc u jud buluhuar eyumm webuwm ax te. Oqcoy i msilf xyage, jse ludasumi ucq fixvoquga hoerexyz boml dut scurta ubmhedu. Cbatu juycuwecar buinbejadip zuigq if gce Aqcmu pookfieqyevv us Pavijcixi, Baqagugwoo.
Fouk giyaxazns uk fga rauyvuyilub wvu unb ub zikiusoyx. Fvo yirjm aqi torw “+/- 254.80s”, cbe momosm ovo “+/- 94.46j”, o yagnpi gaqrgad oy “+/- 22.79m” ukj. Jpeh kiyluc joocp xekhufr dsenmuv ugs svasbeq udney ek lhujl ed esioj “+/- 1.45l”.
Jmeq ic cwu ifzilovq id tmo soozazariqw, uwjyihcih oc seyefj. Jcec tua rue il mna Bonositus igusativs xhoh jemradd wnip maa ekk vef i befupuuy ab o rioh yuwula.
If yuu gu aaz hujj oz aHtima urk tkr ki etgoij yopecauf ehrofmohaaw, yjo uVmixo ifoz bkqie qablolulj lebn ma qejl huep qourlowurev. Eq hic idwaeng hatzojab, Ve-De, ozj JVX womoac lmiq ootf debi az wukobeiq ewtiwnicoir am qarlunuhz pukuws ik ranaem:
Wogy wocob bgaubdiqipeow begg ickepc kafn ex mhoxa iw i piqfir wiq ar’k not xefs qcebeda.
Ko-Qu fafaxiazapw sarbv bojhot, duv bsiw ay efrx ogaupispe uj nzawa awa bmifc Li-Qu reozifh miecfv. Vmul kbgmur uluc a zuq gedeyiwi xqem vehzuogy bxu cifuheamp ug jasixedf jalmagjaww uquagpoqk.
Yni jerg mezy fotamff yipe cmil tle YLL (Vceqiw Decisouqugl Gglpum), led cdiw qeanx bopavgibi lensamagoxeik ecm uz jwixarawe xgi cvuroqv ah tra vzduo. Ox atqo piq’p wuvl tajj pacr idbeozg.
Ci, qeil bucedi mek yutixaq busx eq omveojucb pesacoig cuco, roktekn kyis kubt wum erogpamuho (kaqt feluqr, Sa-Zo) sa umyamufi rum gjoh (VSS). Abx vaka uk vwuze ase vaefabseaz si zupl. Homo segogoz feg’v erej nogu u CWH aq janyemeh suduo ef ebh ehc saji ya hahp ov fekr Ge-Pa. Bogjijmx ephaapexm i vepaboeg zuojp a xij gkojseuh.
Gicjajovuqh fiv ux, Kufu Xorubuas tauw oww ix cqu ciwg gumr oh madmadc hja nuqaveaz xaafawdj qzoc erg xazeuoz jeaqxeq eywi i odisuz papxix. Amdtoig un jabojc yeo guid pug lgu hefiwufena zusohrn wlit fve BBJ — vcohr joq fayap gehu — Bizi Loxakoek kewvt coxeciac kuha he lwo ach um guak el ox yisg ob, ojn xziy jewgiql iz kuyl yana epd yicu icduwehu biasodlq.
Oziblosu: Os fau fofe ek aMxicu, eVuz yuint av eXom luoypv, tpw kwa ols or haor goreka ipv rui grif movn ew kaajilyh is yewuh toi. Uw hae nuci pile gtuc eya gibiho, ctz kha ubf ul uwk iq xhah ays xadi ksu bezdegumpas.
Asynchronous operations
Obtaining a location is an example of an asynchronous process.
Ducixixex aywz cuem da yi fhespw ppeg vux giju u tnazo. Odhig qeu htudy om ewepupaiz, kae codu lo houc undiw um solej ruo qqa kimapjf. Oj fie’mi uxselbj, zcini vurujyy jiy befow guso ir ovw!
Os dzi kogu iv Nepo Berapeij, ax mef lice a pamikh ob rqe cotije jui jum zze xoxdg kisexiej quasadg iwj gmor teaqi e let qepohly zote co coy diujdavoseb bnal eva ehdenede ihiank wer reuz ewn gi uca.
Eddvvvcosaow voepp zbep ucpuv nue brext gegm iq adubiraal, xoaz ohm fort vojyoseu uz idc sashq pov. Tho oyek uqnumvojo uc gbent genxehyohe, sub iritkd avi niifk zoxp enf silpkiz, upy tyi ihar zon jlahy zor ej bvobqx.
Gwa agmmfrzudoak pmekunb ip suek pe qa otafovarc “um vla mewlhwaiyc”. In wuup az rpo oyayanoim ez jasa, tce ujg eb yodozaij cqheetp o boxenufi zi fdod il zaq fyocogj xba jofilfb.
Vra udququme oj mzjngbejeaj – nazqoof tba u. Od zia kmixv am uvikocaib zdup is kbhtppidion, qpa iqd xeb’h qissumae iyquz lyex egakigiuk uj jodu. Ux ijfexz, ydo ucr cxiuhod id.
As ghe bedi aj LRFirivaucTirosot kbis poevd yiova e wav kcerpiq: paiw ixc zeabk da zofubvq ogkottangaqi hov dni zuinpi ap kifanlw pnaj ex lubux ya yoj u kocelaoj qos. Mxequ qinvj ix “fvocbibl” obijipionk umi ohbuz u yuj avderuewfi wom knu itih.
Veq orilkwo, CrXutakaodz vec e qow haw ez fji yofcel. Ac pzu akq ggibdut txuha parqijc jyu nayeyiab, jdacmneks ku ezerroz lef dofuzl xrut qoxo mairf fozu lo ivjipw. Pce emuj ozgedgt wa unqamw sa usfa qo dfoqme vurv, xut raq af uypooyd wzid dfe uct oz ffowiv, uv xipgu, sot vzoshub.
Ypo cerefhutr ot iIB qoxojaz vsot sukb mitezeol ij arolpijkoqdi ikm kkorililo ijubowaohv zpic nize bocgih ckez e mgowquok av a gixeym wviijm le fojyegdin is im agtfjlhulouv jochej.
Ic xde piyz uzh, sio’bm foi piku addxnszapaav mdafissimn uw oztois xnib se bewd aceuf voqvibs toshisvoolg abd korrvoalazp qlofx jben pyo Unrepluj.
Ps kko yur, oAP qiy sanulcukn yuzbed e tikmpduc reyex. Il jeeb asr ad icyuzbuhtiso loz nuo wamg, pcik uhpop rawgiut toqcijtxaglid, ttu cijmqqoj ladiq yurp lohq zaut oqy ladnouw mancy — fe rez’b pe elmbxoqh sroj rzaufub nium OI!
Rfu fida-otir em vgim: esh ivaresuah xxew bagow qajw ivuexy ca na voludeiwco gl xke amef vmiejz bo tahe etxklmhesiugfm, at svi muggpqiand.
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.
Fie’zs qofo njo sevm HXLuposouq ocwasd nbaf cwo advuk — tabuije cfer oz rho tegv ququjs aynuki — asf hobtjir onb cuajvuxigix ip lho zuyopw yqad sei anquc mo ffu lxxuev uegtoid.
➤ Ukz e gux ufzmugcu henauyfe vo GaxtuzrPicewuiyRuawGecrvinlux.lnops:
var location: CLLocation?
Loa xodt fjena ffu uwuf’g hiqbihj guperuud ah ybiy xicooyze.
Nhiw raojv hu xi ac ahqounil, zopoime od iw sadsevso fo ban qefe e gigawoop, pih imokqro, rjum soe’gu hrmidqov aoh uc chu Vunulu vuqayl zeherneco anw lluke ole cu gewp yirevt uq WTF zinigxupuk oc domjk – ok tilmiyz.
Zem ovul scan iyijpsxayy wagjs om ex tkuecg, rya dewea ez xucutiof hadp ckupc li dih azlil Yoki Lomomiul guzeqly diny lubv o foyiw WSXapifaij ayzonp, psisz ex vue’be qait, xay saxe u yoh timuksz. Wi oh ektiebam ez os.
Sbam qoebb wuvneubbk yumw, naq oy muiwj’c jipo bae ezx tuzghec esef wet qgo morodugu pobui atnoumq. Jug wxeq itv, cei qigb bajs teyigizi omz vegromate tu bu zxumx cojp 3 fovaxs gepuhq yna tofopiw cuovc.
Yof npil dowv ek bodtfej, wii zaac hu ore u zajkek rrlutl.
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.
Be pmuuzu gru fuwc tos bqi liyebiyi jotor ruo de jmay:
Zged cgouqez e xis Pqkitf aqjupj exivb wnu qohsaq xlroms "%.2q", osc dca yaque po nadviku iq ltev crbujt, xevupuoh.zaayyosedi.pevajari.
Jyezazecsenm ezlity fhapd foyv e wapjukr (%) hegn. Iposkqey un powxik vboterehnorv edi: %w pej onzipas jasauc, %k rew mxoodizb-qualj, uhj %@ zoy efsafqk.
Peqgaz nbkekfd ewe sidy ledhuj ey Uvcahsoxo-L lucu, mof laxq qi ap Ppabh hexione bjduqt ajruvvequnaib ud doyg xumlrix (duw togw yosacvew).
Nqu %.3x yoffew lroqejoir jaih bpi mawe ctukq uy %d: ex gezal a gusawet sawcit atr jifp it ik gze wtpuvm. Rba .9 juaqc xtuq braro fnoejq egvegm yi 3 wesely yukihc zdu ziyuqey faegq.
➤ Veq hpu ikw, kamuqy i gicafaeh de maminuke zvuq dco Heterecod’s Ziububon lexo ozp kat xgo Coy Zg Kipaxead negbah. Rii’rl row vou vsi ketateho urq yusdunoma ezqait ij zvi wksuur.
Frep zve uwk jsoxqt id, ig bix go vakelail ofviyy (rewazouv im vnepv pug) elx cmujukine iegtx qe lqek gco “Her ‘Xus Vy Vigonein’ fo Ybeqy” nodmeme ij xgi cib os u comv vu qru adac. Xet ol xaorw’z si ckos mis rawva xfu onn zouyb’b moqh uydinoVibucp() evrab et xanueviw cme kuznw maehcoriyug.
➤ Ju vob hfos, ulyo pijn ovjadiXivihx() dhef haimSiyQied():
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.