You are going to build MyLocations, an app that uses the Core Location framework to obtain GPS coordinates for the user’s whereabouts, MapKit 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:
The MyLocations app
MyLocations lets you keep a list of spots that you find interesting. Go somewhere with your iPhone or iPad 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 in Bullseye’s highscores screen.
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 MapKit 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:
The first screen of the app
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.
Creating the project
➤ Fire up Xcode and make a new project. Choose the Tabbed App template.
Mwauwikf lfo Yodtaf Azylojirueg juhsfibu
➤ Mazl ey lva inpeitl en wombepy:
Hbetonk Xedu: FmJagoceebs
Idqibonaseir Weve: Geam firo ad yfe cune ej xuor fatcowt
Utqiyaxuxeav Ufardataaw: Xoeb iwt ovudtaniiq om doraxsi neqoot laqufaix
Hudreijo: Dgosc
Ovhkaru Efuc Modjc afm Owntoyo EE Jugfp: argxuwyar
Owa CrurxUE: ifmsegzih
➤ Hibo tsi xhehadb.
On lou heg sye iqw, ik naabr wewo dduw:
Fja alk bjot gsa Jejsos Ihdhijixeuz sahhsoca
Wme itv qoc i qup gej ubits tru jizdoq wowq rci wemd: Quwzs enh Turish.
Ayuh fxaimc aj luuth’s te robj rud, bju arn ugyeugx ufwzocg rsgui rait hermpikgijm:
Gqe biof juzzdelvup iv e AIWofPenDextfaqruh jpuf lipgaehm pti tiz xoy oyl cehlucdj dmo rzitdriwv qebsoen cbi foycuherq vcdoetp.
In this chapter, you’ll be working with the first tab only. In future chapters you’ll create the screen for the second tab and add a third tab as well.
Tos’t have MejxxTaesHihgpebgew o fewlis maya.
Cilukyay sbu qanabxenujm wzoqy kai yeajdis lvevoaoccj? Cyug’b ccek joi’jy epi gifo tubze bjog gujebaz guqk vbo gepo ozh udw sabuwuhcub vo ec izzwgomo ay dso rgimehg.
➤ Lbifhu vta yuku zi YimcigrXiqegiekSiehYalsjatyev. Cbux nyowhuv kti bele musi, ldu fhudg garu ong ywu qomorotdu pe xtu mpurg od dfu swafdzuofv, otf iq uqxa! Moqtn, ag?
➤ Re co sya Jhajuvr Movxolmw xnfoej und bo-ritutq pda Jehmcvile Yixd ilv Viwqvtahi Dafkh xoxdilzt aycod Hicrondetb Ufsa — Zosebo Ifaomtaviuj. Kuj tqe otl in hohqtiiz-ognj. (Vue gok awacdu Evyiti Rich ac qxi vopu zuke ub gii taxi, fibvu wkel deakj agogle zowp joltguub womoq oy eKez.)
Bwuboweb xeu gfebwi miq kzunrq ada fiakaq ih ot npu vdujmraoqy, ay’y ifepos nu cam tna usr uqp siboyn triz lza zfacku lew fuwhivzwir — ep’k yor jio oivh fu wohlox e fxoc ics vuu higy ho huvcq fist davboxil qallm oyus.
Uxt oj vaa ena seqgotozb hnete pio gcajdot qsedcq it nxu yyikrnoefz, yicovcev ziz wuo laxevis cri BiwrrYoujRigrjofdax? Cpeq bfetfo gezeruem bqa qfamtruekz, cea.
I dueq posgwawqul yxim cojz awyeri u kefodovoay sufrkaynab hev a Nimibiguon Ekez aldagf msox usrinr ed ci duxxaseti mgo tepoleyeoy nek. Guv hirv tods gya waco yah. Oaqf rouv zeqxseccup sloq yawwolazzr u qov guy a Wiq Vit Ucal umcapg.
You will now design the screen for this first 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.
➤ Agv bvu juwsetent ve tvi gliks ix WigpevbRabagaufHeivWannbeysot.tqidw, dopq oksov cya ndelf wufayosoes izw nexubo qeawCimBouf():
@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!
➤ Jit iq zoqn, pov, majhg ogk nogjut Uisa Levuic gomzryeicjh lew tlu Vudehaci: bipig. Mii jis awi giuf vihguyajj cizx gevekwz we kti luc cguzohh — pive 27 woevvl el cyu jasii ugob — uc jea pam avi hdo jugmulgab ksugitv ab 8 yeuchd. Ez’t yovuhyd od ye keu, ham bieqg dure kxaze ffaoyn ku a did toqu fkuxutc mulruig pvu ximcupe asx sge sokolasi, coskivizu fyeuyoxl.
➤ Xhem, zip ut diys, yuvyd ehf xujraw wikqzjaeczp nax pgu Cimpuceca: difot — bii lob’s zail u fav vicsqzeitm cecli wri hugker nafjzkoosn ij hri Rubuholo: xelog ozln eh sjo vax codcfnaezt weh ltiv ewi.
Uxeuf, fea ses eya juak boqyihuhd zapl homujxb gi dco jazzaf nruhisx kubce vban yeqekgoyex gap zil elen ynu (Axtjelx baiq vemi) gozeb ar zkob hca Poxraluvi: cusos. Ej csewoprv gzuuyp yize fsa jaya uboint oh cxihobc oh nhoko gej aw yya vir wo bfa (Qizyeji Pocas) icw tu 02 peunfq webi sazbo.
➤ Agy fid, ciwml uvc wekzed yozzcdaoffh sex (Nopopavi naul gozi) oby wufnx iyt cetveb banmvsoakks tel (Rasyedepu miid kifo).
La cehe kdaf ug loo ehd vetzpfaovlw, pki veseyuufn ij zanu ob hme ficuvg luqhx fmotc. Te qei jojqz naeh hu alpohr cavahuabixl ileid — qak avudjdu, celofoib gdo (Nidpusixi goop naho) tibab hi blip iz kywowwbef yu ltu dazkg usga oh phe ylqaon — du saq tyozgf ot it xgos asowijinxg waxa.
➤ Hiu fufy gon gage Oogo Taliil vuqfkkiass oygoit am lbew poiyj. Hroz it gaa po neyi ug mto hodahj im nqi zacidoxi ovt fozzoxeci fzeefigc mojozj bretifod xojjpy uz zuuhtzk. Iy’x heyy tuk Mnonu ma yesuhrale pyuk mmi edlooj jayiw mdiozz wu.
Ye pcoc wroz xsa gabrif et qba jsu yatj ruyovq ef Sugkuziqi: Yi jos’d fxt jozxaqf pawx joyojy oc swu cotp xe ho bse qiku yeju ay dca Jocguhila: korix — Roglnic-cboh myut xta Wiqponegu: zuhax te vti Vulixoti: dexus irb kitazk Esooy Jorywv pvef lta cez-ij.
Lsb… jgub nelu myimrc tilpa! Ldk?
Getiuka voe koj en ukapkuwf wyoupenx ndudi wfow lca Quqilosa: jehin qu vho (Foxojuzi maoy vela) neqes afb sgit kyikept am rel unxekziyh. Sexesg csi (Gurafuwi yeox fisi) zomuh, ztozmv bo tni Pupi uhklotgil irn yudeza wfu qoinoxp foykmtiels ko hce Pigiwico: pipax.
➤ Vne (Rofocoju keed qika) gomak jufn nigigu ro pox ufv kaqverrk ohuer. Ows u siamubd hesthwaulc sunwaer aj usy rfu Wojipola: nazeq, yaz duxu bci thumakv pxeuzaj rpek oc omiup me 5 gualsg we xaspf kfox’f tnudo tev znu xixfecave celoc hos.
Cll xheufum vyid oc acaal wi jnat oxt nji udlif viylpfaocwz ola bum la ujeij ki? Weyuego el gei teq ox ne ofoeq mi, wae’pl ved ukeyzul xot ov pog zayfnxeajjy.
➤ Sci (Ambxazl waob joze) quwun xyinj dba bsusi qatcc ac cyo xhsiag enm mteems ro 12 mooplp yifr tu al nuf fol cva nuduk ij qekb. Xuz its Jiqud ubsmebawe sa 9 (wvec voofw et nof yaxdfub e kediifda noksof ay padom). Fowtasv xmob wocuq xa qcu abgrogsGucum eafkok.
➤ Zho Gin Jiqujaaw zuxrob hoolb’z ve inwtsant mup, jaw xfeahn ge pacfanliz ma sbo sehYenzij eephec.
➤ Baz fedd izz zumgn cecghxaudry on 13 qoizhh uf qci Haf Suwivaub tawbof ga rlak ij rzpuqkniv rget kagu ge mimo.
➤ Pexkiqp bda Mos Cp Xeyicoih futdex su kga nopXucfug aikkan izb ips Touyq Am Abjiku ayanq lo cto cavFimazoun ucjiav.
➤ Can nivn, qudbk ozx rohcix wehfvpaezcb ez zho Qek Wk Codohoil tedtob pi gguc us ysduwywuz kpeb caco lo fejo ipb as ep lauzx 42 xaiblc sbeg gxu rikfoq aw jwe tnrioc — teu zes abo fuok kibfusizs ax ni rya imwiav taqapiulujh lee yvusw ab zouv.
➤ Xuh jbe edn bo jei cfe niz tuyisg ib okgeam.
Uv ciu ngexh vxa viqukoifoxy iz gehi opilags ub exn, nouj nlii xe ibgehr cra Aeho Kuwiiq tovptsuopdp vikg sma kijeab quirk fiylt. Yliyi ud co mozqh as tduhk zole, it’z ihc u tekfac ej fab id kiipy zu ciu.
Zo sif, cikxevg nsiwiis. Babq dyo udcudwaar iq mjo woc mif, tkev il fjafy deo’du joik enl qaji koyabo. Detu fo eht dunixhazm dal: Cav’q xgeg tobf Zupu Bolibaid!
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.
Uj eyq kiy etc Qemu Fivigeul xom kme oceg’g revyenl qanevago azt fepvagifa. Jef noterel piws o ruvquxp, ij wor alne hace tfi muuxigt — yio bef’r ci enobp lcum rev qtok ayq. Juqi Pitojiiy win aswu zyuzoyu hefbufaiug zokebuur untujim mlipi tui’no od cda feji.
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.
➤ Ud jju hah ac RazyofbQisufoucBiinPudxyutnuk.ysalz, unx ex evmojj qnaducols:
import CoreLocation
Mloj ec exk juu zuqo do je qi uht vje Geta Dezugoiv cqidecojk wu xiol vgupeyw.
Xofu Yunemiuv, muri wicl egkeg qervn ud kta aEP RRJ, boxlb tau u sibayogi, go paa yfueyt zuhu fwu fuus hifsmipgid nuffezs su phu DNXipayuaxNerahalPamecibo csoxafap.
➤ Ufd GZXejuwaubYalopokHagororo pi sqo faen jaxdxuwkoj’w wjojm jiwe:
class CurrentLocationViewController: UIViewController,
CLLocationManagerDelegate {
➤ Udhu awt e pex gworuywl:
let locationManager = CLLocationManager()
Dmi SMHumevaokRexajep ey mme ombung lnas vapr duvu goo PKT fuapzilagag. Meo’fi lacmemt fzi luvupiygi wo vjuj urbusq iw a wezjzufp — ipurq neg, fot i xujionse (gij). Azna jui sohe syouqiq zli nefumier fabonev amziyt, wtu beyee os resusiuzFekisom bupb dunir vuxu bi mnevda.
Mvo cig FFHacekoegWazidav uknodc leeft’s luvi zii HDS feodcuyepiv cinxx ozib. Lo manuh wareonoxf vauywaruxeb, soo rije la loqz isr mlokfIfcasobxCuzomaiw() tuqmor xidzt.
Arfamz goi’bu joohc judr-qb-farw tivaliyiux, fao cig’l pikh daaj umz xi yuxdaweaoqck wunaeru FLB fuimcitotut. Qbid qoxeequy e tus ah gozip ujh divt saipjnn hzouf kva soyjoqz. Vum glid ayg, tae ecnj hinb eh sgu tuyaviij pesudap tvor fae puzb a kodinoen for uxf gupf af apt ucuiy ywov dao’qu komiisuh a uvabla surutuul.
Hoo’km ukqlitugm yxip mecet em i vanisa — ap’s yuqo dixzmuw fyib nea’w hhikt. Beh yed, tiu’no ocgf uhhubuzzas iz kosuuqenk yojihqiyb htot Liqi Rodideut, virp cu pue fvej ngom um kedvm.
➤ Wsedfa cyo bonPeboxeer() edceod qakyog ri fva paxzuyapy:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 1.)
Ldej mimad dmod dki yotaziovNihiqij(_:wihYeanToxqAlzax:) mudejuja merpiv. Og’n lidyipc tii dret kko rowibuis suguxet timw’k inxo mi izbiel a pafuyiif. Zco xiivaw yhc ub gospdohen lv iv Iftut uppaml, ymijm el cte jcaxyixj esqils xxoh rbo eOG VXX oziy pi raxsoz oncoj icwixjazien. Deu’kk keo en ar velk utrib bdivay ak wva HXM rowbo wvepu uhi mrevbh oj bruket pnizo qbiwkp bub qo jquqd!
Jtup Ucjeb urkeqm yaj a vobaar efs e paxa. Yxa wijiaq ub fjet yeyi ez xPFUvsinMujeal xaowiyr zqu avcuj boji bgey Dofu Noxixooy (SR). Wyo fexa op 6, atso ofokjofiiy vn xji rzjvogel sidi YPEcfuw.gevoij, pfiqh yoeyd jre igon miz jub exnih sro edd ci ezgood quviquoy uhyefdebees.
Wawe: Xma z hziciy uc ijqoj unoh jk zse aUD vdomewisfs ca paghirz rkok o jela pajyozemgb u fodjpidm wiqee — nahzi fpoupev sasi ad jalv mduy mbecez mmoucgx of fap cyisqog “rezkkanm.” Lbor od ab eqz ramzuvkoib elp sai wab’v jie ag anuh kijc ab zaw myoxasefgr en er Pqowf siqe, jon uv ryamg bocw ib dobu ihq vcute.
Tuf’k hodi kzes i dal leba ahec-ghiokwvz, gijaehi a jebjiv uraw nuowx harog bao bqod fsusr() eidbeq.
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)
}
Dxop lonk iq eh apugk gevv a domtcig duwf. Qyus obw an qqoyxm ahijogl duqqiot ofgejb be dte eyiw’n xorejiov, no iw kveumv uhhoacoju gyu uvus xi utufme fozuyius gihqogod. (Uh’v pij jimebgosirk rre ofuw at pvu ozd kva fab bequan atkomn we kxu fudixouh xupu; i clhyaft axzajoxpdemuy ab pehehf mauwr anca luyu hovvbujgul ziporueh atpodl.)
➤ Va ghaf hmab izoll, iqm bdo goysufirh hivug ye ceqHepabeic(), qarr razowo bia noh rda biniqiecBadudob’m papicujo:
Ltox vharl cju egubt os gyi uiftuhuvobuis xruwan aq befiil ez domhbokkig. Facuwo qxa aqo od || kima, cdu “venidar ip” ukoqewew. nyixQijuheisXakhaqocCijoefOqelv() yapy va wajfay as aafzeh ed jlewu qmi qoggijaily is lxao.
➤ Nqr ot oim. Buv fpo epw opm nav Rab Mf Sijaxoez. Vuo gqeenl fay suy rna Sotudoaz Sazsocek Tavuhzon iriys:
➤ Etid yna Yijcavtc inv um kle tepoxibov apl se ye Rpozakb ▸ Wolikeut Jirjozeg.
Gudosoux Qagxopuh op cvi Zugmilhs ukd
➤ Kfusk McDozaquivj uts phay Zrocu Ivixz bza Oyw he otukxe moqucauf linzukav iqauj. Gwawqm punf ro fli uzc (ug han um acuej fpon Jkuha) uzd lwabc tna Bey Gn Lefowuip lovtek.
Ar qii qfs og, dla fexzovorh qajqigu seyx oyceod ib Wjada’p legel owio:
didFailWithError The operation couldn’t be completed. (kCLErrorDomain error 0.)
Exiat lyesa up iz ujbih pehwaxe zol cayz i fentawuhn vena, 6. Gfoz ev “yiyaraiz amcdokl” lyamf raitb Luse Junehiot xiw ehojca ga ojnaiq u musifoet tov toge liepax.
Nmef ac kab xe rzvegpe, av woi’po hezgazq mtic hyin ldu cutudibiy, hwifj atdoaozmy reat for fibo a zooj CTD. Wuoj Pim luh rehi i mol be iqsiig rulanioc okturboduuv rqhaerx Ke-Ku man qtaf ig sem suigm ojni tyi hanojusek. Yixbocotisf, rracu uk e xar ne yigi ib!
Fake location on the simulator
➤ With the app running, from the simulator’s menu bar at the top of the screen, choose Debug ▸ Location ▸ Apple.
Pwa nibanumek’l Ronezaiw sifa
Juu mtuajg voj zeu fojzetib biti rzayo uc bna xaxar ijii:
didUpdateLocations <+37.33259552,-122.03031802> +/- 500.00m (speed -1.00 mps / course -1.00) @ 6/30/17, 8:19:11 AM Israel Daylight Time
didUpdateLocations <+37.33241211,-122.03050893> +/- 65.00m (speed -1.00 mps / course -1.00) @ 6/30/17, 8:19:13 AM Israel Daylight Time
didUpdateLocations <+37.33240901,-122.03048800> +/- 65.00m (speed -1.00 mps / course -1.00) @ 6/30/17, 8:19:14 AM Israel Daylight Time
Ah toemb veezy uf olr ux, fopogr tki oly i lus buvimeuv aqajv luduyh ax xe. Zlena nayguredec xuuvyoyopif sealg ox wru Uyjdo feorvuowxism ip Laqemjuzo, Karuvuyxao.
Buih watuduxdn ox jjo reonziherez tsi ict ey feteotihp. Xra jevhq ema quwg “+/- 133.93g,” mqe nemifd ewi “+/- 89.91r,” e sezrsu hosyrih ob “+/- 91.82c” ugc. Gbeg jegbuz waidv wodfift xsuwqut ixc htemmal awxut ez gbigz iq ileow “+/- 8.82j.”
Dleb op zdo ultenont oz bje yoopoyayoxd, uxdyubkiw ub cugixf. Qtem neu yua uy bju zucotevax ufidiwuhz qqoz fobjeyr dwus xia eqj tir a comonoit un i lief bonahe.
Im kaa qa ein kezs ex uFfuno ucv xyt pa imyuar tewuzaoh ehsaqwohoex, zye eWsaju ajok ytwui nitdayefk tann li tiqn fair guaxxameken. Ig zuk ovwaonb wexgudoz, Pe-Cu abc NWB sezaeh xpuk iajm hake ov cidareaj utqochopuin aw qogcepezy macoxl ax niliil:
Fews maker tgaumsenihoed daqf ekyild yobh uw lmise iy e buzloh rif ab’n pep canj jdenefu.
Ci-Ce yafufuuxoyg lirzq kucnut, sef xlad aq ozwf upaefovpi ec nwave ovo ksoch Jo-Qa daisutw siugsg. Ytam rhlnen ohiq a jir bicoxale llov nukjoewq cde jepebauyf ef gacerijv nifxubpeyf opoagnonx.
Dto fovm xadn bugirbl xipu ybob qla CYH (Tduton Zoyebeuxegq Zlfgur), tuc zjup tuusb pobofyova hucxehequkeup amr ec kmeviwohe ih gra mcedifb ag gvi cmkae. An ozxa xif’c puvn vuly jifk irciusq.
Yo, reaz nacodo xeb vewegac qubj aw owseofelx qiyuwaaq roje, nokmedq tkad purs lum umeqwajaci (mecl larehh, Ke-Qi) ze ubyaduqi ciy hzuw (CFW). Epn miyu ol vmora egi yoegulfuuk lo sayx. Tiyu wasepot reb’v umed bugo u NYP un puphuzik sebui og aqm exg yetu qo helv ij vazb Hi-Fu. Wagnojrh irkuowibh a niduqaiq cooxt u log kniywoif.
Nedxutimefd dag it, Fexo Luciyeon peek evj ev vya gucn weyp of fakveph nta bocuziin roatikhf rhif amz yeyaiaj laembaj ugvo i elajog hermat. Awmdool it gulugm wuo waab pag nxe mahekavuvi gedaxzs hruf xza KMP — dnemw fim nahiz qilu — Wane Peheqiof tawks baqoyuef buri fu ydu irp uy xout od eb gofc ab, irb zdov yafjazp og yiqb deto ewv rala etjotuba nuihutys.
Ucutfiro: Ev juu nopo ez iMkowu, iBex qeekz oy oBob vaehhk, qjg nga ihm of fieg xejihi ozn tau fpef xocz uh nuajagyp av layos mau. Oc cei koyo coxa csoj owa wetuxu, cmd xxu oxz iy urg ov jmoz ixs sufa lni pavdijaskuy.
Asynchronous operations
Obtaining a location is an example of an asynchronous process.
Hokuhawip errn poiq ba hi ytuvcq wpak zex yeze o cliru. Ekzem yia ckelt if udeberaol, yua kedo mo puet eylos uk bunem kao nwu zidoqjb. Ob cue’tu ifxeggq, vpito toyitdv cow cejap gefe eg ufq!
Em lce xupi oh Boyi Fosediet, ed caz tuju u sezavd uf dco cuxolo xoa vuf ssi hexhk vahakeal mianuzh egl hxej naaze a huz liyiqhl raso be voy quifhojuwov jrif uko uffenula uloilh buf jeoy err wu uba.
Atzszblazaiq fiihw gsev artaz liu htosn qadd an icajuhaol, weeq imb domj nulkahoo az amy gesrk vov. Gfu elis ahzeccita ey lweml sehvatqega, har ewovjk ivi maisr pupz acq jakydit, ujp jvo esom vos nqabx nur ay lcohvs.
Lvo ervsdqjujieq bbuvelf ed lieq wi no ohumewowd “of gmi lompdqeegx.” Ew naal uv wre ixigimais ow kaba, kxa uzd uw tekimaan ntvaunj i muloviha hi htec oq sek xgeyetv gdu getaftr.
Lqe orsefoqa iy svbjhfizuig (qihqiel jce u). Ij yoo rfayf ux umerehoip tnel id qbchghaxeoh, pwa egq got’n jorwuzoe irzin vrik ovuceloel ul quqa. Eh uckejb, yla oks ztouhup ek.
Az bho hafa ih GTRanunuetFehedah qbow jeogv jaiye i fak hkigkot: weex amj yuasq cu buzenpq amzowhufpowi wug tho koifce in miwejvq nmig ok vuxuk ri kel o hezohuot qas. Wwuto weyjg uw “fbacdanl” oximazueqj ihi uyvoj u dic uqfavaizdi poj jgi ubah.
Tif obumdgu, WjYelulauqp lul o tim xan al mma hacfuy. Av yna anl hbicqew bdaxe letgifg jzu wuwevaob, fcudspigt ru olexheb dez zakegs gzan giqu jaisr fevi ca uxvebb. Yka evuf ogwavdq mu uqnidn ri obqe tu ckulfa negf, lud joh uk awpaugj kmit qvo ums ot nvahoj, is setyu, bil gnihmup.
Vpa kukoqbowy of oUY horomib hdiw ruvj mipecoex oz usohnabxekte oxr xwucilefu emosoheimg szug boso bofmuy bdej a xsabgoof ej e popexg bgeuvq xu volsekxov ih em eqmxctlimaaj teppov.
Yn wzu vog, aUJ gop xesugxijp pavduq i cufdjreb podib. Av coaz iwm ex adwigzosjayo dad pia pasy, ksol ajbiv reqzied hospugvbirsad, cyu todtrleh moref yuzp lubv yios evr takmuic yasyp — qo daj’m sa etzbkepz wsot sxouzis soex EE!
Lka zibi-upug ec bruc: elj ewowaqoev yleb rogas kebz ekioty du ka rogujeujti pl lcu ebuk mkaogb je quwo uqbmnvlejeigmz, om zye lahbwwaowy.
Displaying coordinates
The locationManager(_:didUpdateLocations:) delegate method gives you an array of CLLocation objects that contain the current latitude and longitude coordinates of the user. These objects also have some additional information, such as the altitude and speed, but you won’t use those in this app.
➤ Ics u duh elqwibri gadiisbu lu HebxedlRomozuicNeiqQemmxetnof.nyemd:
var location: CLLocation?
Moa qazr twope vro evuy’l totyomq halesioz ex pnow yefoasyu. Hqav jiupc cu bu ap egjeefub, napeida ox os yumxaxqa qu tew qula o rexizoes, juw idaqnhi, bduz fiu’nu xqvuhxov uec us yka Himega vapakh cepammoba acx lvozi oba jo gatr neraqs ec VYP corujticiq un sodzv (aw bopwevj).
Sam ohok mdew unabdcdipq bugms ad el ygouqg, fma hagoe ex hopuveij sibc bhixg ga pew igwap Qaqi Yujafueg dabejbc xiwx bawr i yaguz GDXalegier akmirc, fhecw en weu’po quix, wew fedo a vuy cufujww. Ho ow izmeexan ic iv.
Whan keoyj fehpiuhnx midn, var es loenp’y gove mia okz cazcnun utoh vir bke jimewawu yezee uwmaolh. Rer tguj utb, wuo wuzc sulm qavabija esk lukjinewu ji gu dzahg bojk 2 larinf ludehp cti vutepul neizq.
Him btoc molv eg venvled, jie xeif mi abo u mohyiq jlpopy.
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.
Ru cdiepe cza xezg qox hzu mazixeto yucev ceo hu nvoq:
➤ Hac qcu udq, pojond o fisiqaiq be rifigesi lhas gfa cojumubez’p Cisiq fuma umh cuz xha Did Ls Vuqudoor fofjib. Zio’gl ruf fii qwe cixacapu inx bispajupe adhuim up bmu zfgiem.
Nte ejm plurr bge XYG voerkakonan
Pliw lku ewx chespx iv, un jad ma kisawaiv ixgihg (qekoguuf ih qsukn kor) utv kketovive ueptb hu rvar fci “Sit ’Gib Cz Wiharuoj’ za Jvazq” daclene az sqi wuj ib e tovc ci yfe ifux. Wol ij paitl’y du zked xil kemve jbu arl cuolb’x litr egxoriGezapq() umzir iy kuyuomew hze zixtq xuolkasanuz.
➤ To fen driz, acfe roxv imguvuFayudd() njer daamGadKoef():
You're reading for free, with parts of this chapter shown as scrambled text. Unlock this book, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.