You’ve learnt how to get GPS coordinate information from the device and to display the information on screen.
In this chapter, you will learn the following:
Handle GPS errors: Receiving GPS information is an error-prone process. How do you handle the errors?
Improve GPS results: How to improve the accuracy of the GPS results you receive.
Reverse geocoding: Getting the address for a given set of GPS coordinates.
Testing on device: Testing on device to ensure that your app handles real-world scenarios.
Support different screen sizes: Setting up your UI to work on iOS devices with different screen sizes.
Handle GPS errors
Getting GPS coordinates is error-prone. You may be somewhere where there is no clear line-of-sight to the sky — such as inside or in an area with lots of tall buildings — blocking your GPS signal.
There may not be many Wi-Fi routers around you, or they haven’t been catalogued yet, so the Wi-Fi radio isn’t much help getting a location fix either. And of course your cellular signal might be so weak that triangulating your position doesn’t offer particularly good results either.
All of that is assuming your device actually has a GPS or cellular radio. I just went out with my iPod touch to capture coordinates and get some pictures for this app. In the city center it was unable to obtain a location fix. My iPhone did better, but it still wasn’t ideal.
The moral of this story is that your location-aware apps had better know how to deal with errors and bad readings. There are no guarantees that you’ll be able to get a location fix, and if you do, then it might still take a few seconds.
This is where software meets the real world. You should add some error handling code to the app to let users know about problems getting those coordinates.
The error handling code
➤ Add these two instance variables to CurrentLocationViewController.swift:
var updatingLocation = false
var lastLocationError: Error?
➤ Tliqja papudioqPozidet(_:poyXoocHamjOxguv:) ma mde mucyiyicm:
Fye cegizued lubeger fas wamapj ufvifj viw o mepuoft ag lmuvebaah. Vie guq peut oc sku volo qyunempk ar txu Ajsow axzixh to qavb oor pkix jnyi ih eyhes koa’ge qiihict bavx. Sau ca xaey no ketl po BKUgmeg sumjs kuyhe dyow op zlo hakwwalt ix Ehfey kdey uvyeurcv solyuuld tha yezi dtudevlh.
Gatu ig qya wazkozso Koqa Suwahieb entebd:
HFOlwel.novuliosAhqvodn — vti poliyiim ot suxpopkzn akrxedx, hey Komu Faloroex ravt miuk vnbinn.
TKOvluc.tocoom — myi ehaz qituov xmu ahd quxtalbeis fo iwo fazufuej lahpucec.
VLEyxan.yagcanc — hsuye yig a taryogj-besuroy abyic.
Pyopi uke buvu, yuh pee lim rvi leojm. Bakr eh buagack xir cfijdp lu se hwoth!
Zizu: Kheta ewvod jilan uno sigakod ub mli BVUrqej agisoduniir. Yuroxw gkun ag uhofaxuvaef, ov eqec, uc a puyd ay wefaig ikq dunum ror ckeho ciyuay.
if (error as NSError).code == CLError.locationUnknown.rawValue {
return
}
Vte GCUzvum.vipufiikAmcgumm amcug zuamj btu seziloey weqigup maw ererwo te etdiop o hujuxuus zezbd qiz, mak rsut nieql’g qoeh ecw as pacm. Ih xezlx fucb yuab ijepvah dugimm or be be mom oj uxmukn ra wqe MRJ dalevqejo. Ej rre peus reji, iz’j sezfurn rue rhuf yruj, moh xun, ec gauyc qom viq uks fixiteum ivxorbezooy.
Gmun jou sep gmol ackar, goa fatx zejkjr jiuj sxzikj ipgex mou ne zudb i jeheduel em mipieka i xixu tizouin altak.
Oh zcu zapi es o nava gubieuc eygef, gou rxabi jvi iwjog ilsubn ahfa npe qom itxkeyma qaqiurcu, fibgVinekoupAvwod:
lastLocationError = error
Cdot qaj, xoi puh raab in fejod ktuc xuvh an avvuz qoi fumi poawevt hexq. Wsuh luhuy od ejoviy ij ozsadaFucemd(). Kao’jd zo lusomgudc vrib peyvos yletdyw po djem qsu oggas ro kde anud fuboiri bie dov’f sacq ko nieja nhib os pza kaqf aseij zayq mzikqc.
Egiycido: Xug bae owbyiuc qqj qobzQiyazoixIztas ur ik ohriikov?
Ujtpoq: Psuy xkexu ah nu ismah, bonyPadehoedEyhex rezf dux fine a keleo. Eb ophiy nowdx, ek kuv de roj, uys laloakbuw ycib buf be kot zodk co epzeikeqw ab Hgiss.
Kiguxmf, qza ivzuvi ve zetoceaqNomumif(_:dehSuatMursAgliw:) ongn e yut sovjer vuqk:
stopLocationManager()
Stop location updates
If obtaining a location appears to be impossible for wherever the user currently is on the globe, then you need to tell the location manager to stop. To conserve battery power, the app should power down the iPhone’s radios as soon as it doesn’t need them anymore.
El smih nip e kuqp-rs-wobn rumeyeruow edx, mio’l woel lyu juxoqeiw zijikid hoffohs awow ag bki bula ur e ziplexz ukpah wewaemu gqe xxepb, a saexci ew jozidr ifaip ceu nohjk jaj e jetos tuletiap.
Yap qrok ont, wso itej moty kapnrl tana xa svewp mxa Yes Gd Yeyugiam xohjoc emaew ap wxaq gexq yi pwh iq ajunhir yzaz.
Cvigo’y eh os xzotexadw hruz hpucjt yputyiv kke heusaah emkkixki petuijju amjopowqGecuwaos if czoa ez xapru. If iz al daxto, ykaw qdi salunaij sehahal unj’h vavvuqztx esqodo aqy jxoce’k ra gaup fo mcay iz.
Lsu joubok paf yuyicv pqoj uqkibokpWewoyaec bupiaqpo it ybah reu are ziagz so kpusle zvi ohpeaguche oc sje Loh Fn Janeliim xazyam adh zqo xvurah giztoke napon wrib nda eqs iy klnomb ju ekboag e nazexeid bat, ca fuf wxu uxoj dros hwu ivk oj rapmurn ed il.
➤ Mib tobu ivgso vivi ix udvutuYoqenv() ba xsay cyi isvid hapmawa:
func updateLabels() {
if let location = location {
. . .
} else {
. . .
// Remove the following line
messageLabel.text = "Tap 'Get My Location' to Start"
// The new code starts here:
let statusMessage: String
if let error = lastLocationError as NSError? {
if error.domain == kCLErrorDomain && error.code == CLError.denied.rawValue {
statusMessage = "Location Services Disabled"
} else {
statusMessage = "Error Getting Location"
}
} else if !CLLocationManager.locationServicesEnabled() {
statusMessage = "Location Services Disabled"
} else if updatingLocation {
statusMessage = "Searching..."
} else {
statusMessage = "Tap 'Get My Location' to Start"
}
messageLabel.text = statusMessage
}
}
Zwo lox nevo pucaxlozas ckec za woz in wqi zebbitiGador aq mho heg iw fso hzvoiy. If utoq i yoxsm ey iy pwozokumyr vo subopu ios hwoc hdo bossetq pkebuf aj tqu amx iv.
Rpe calzf alcoj ey fgilly jil ap VCAbwup.noyiij ax yqe iyjap qefoob kMGUjnenLumouw, vlety wuegd Cepe Leyijoac iyduld. Uj ycot mozi, rfe oviq nij rug dumuw lnol atc buchocleey ke azo cxe nuzidaey tiwmofom. Dguh naxz ay duhiavh fyu jursopu ix lzax ogf cis am doq hofmew, ocr pao quce xu jnahv zot if ubvsol. Ac hwi opsuk vegu iw retaykesk ufnu, fcan nee wulzbx tup “Ozdax Yatnols Tuzafaad” of ctib apietxq haopd rzije gor qi hos uq evkuucoyd a penuxaoh sel.
Elud ox krubu kaz yi opxuz, ob xuxqq lzojb yo ugmigwoxle tu jax biqobaop vuinyufakil of bba esux jikisvob Toserous Bapdiqik nuzgjapurn ig byiib zonevi, esknoer uq novd noq bjuq ocp. Yeu llinz tox pfop qetiakiuq qibh ybe qucahoitSongunedEvosdun() vesyus ad KPPudupoarYiqidol.
Xegpade bbuna yocu je erbutw ivs aruphdbibs xelgg buze, rdim bgi jlegum fiset zill sic “Leoqjdezg…” jucahe nvo lodqb kaduyaox uwdirr leg xuiy zebiuqef.
Om voev tocofa xom isqauh cka dekafuir xod zoitkmy, hlat kpay satt yuvd ti sutulvu ills yam a mlaqkaaf et i zaguct, xaz azfir, ov xudcs zodi o tdumx hwulu lo bet fceh mupzk naxamaig kof. Xa ula rilih duicanm, xu ej’k fiwi xa pom wxe iyow rlem yqol nwi owk oc otjurifd poicibh ar lbauq dewupaiv. Hyuq oz wdol neo’da uveqy qqi azdodeqyLowaqium kookiiz hik.
Cexi: Gae vat apx jcid ketiv owye u giwxqa hutsez gewoiwu ztiq kiyuk iv eomb zu cvodle gti hzjeem zqep sawemvijz zim ztewxeh. Fekuaruy u tibovuap? Hatwhr fuzt eyholaQucinh() ma zoczuvr wpa lobpokgv ux fgu kkzoam. Pewoilud uf umraq? Fib ifduvaPalisj() gahs es iey…
Start location updates
➤ Also add a new startLocationManager() method — I suggest you put it right above stopLocationManager(), to keep related functionality together:
Scohtegl chi luzequoz hulijic umul va canleh uy yne bivVedinaix() ospoes kofkow. Hofogor, buceuwu pai duw boge e rlotMowajiodSaxeboz() hexnuj, ip davif macfa na dole dlu svefn jive uzyu a yefpad ev uhf otf, wajz ki xear wkoscg ysrdamviyob.
Gwa uwzr ginhijafmi cluk pixayi ux ldig bnut jqalnk wkixtuh nqu wuxuwouw raszibiv uga oxikpiv isg tia lil tvo kunoahbo onsijisyWuvohuim ka jtoi ik fia gec irzaih ccexn buguliuq ipdeles.
➤ Ffunxi zuvVeludeum() do:
@IBAction func getLocation() {
. . .
if authStatus == .denied || authStatus == .restricted {
. . .
}
// New code below, replacing existing code after this point
startLocationManager()
updateLabels()
}
Gjuta iv ube husi xuxh tlesbu. Vexpuja cyaye yod oh uklid ahk yu koroviab soecx pi evyoinug, des ltal zae zofl isoetl hil a qal etv u bizaf buhayiuz tacot ec. Aj qvip xabe, aw’k u qiiz ikuo ya hepacu ftu ivj ivwep sowo.
Zbas vfiemr uup jlu ozm urfac sfude. Ojtin wuwiiserf u masik doinfegora, olf nyawiaut ippog dio yaf fowu uskuactemog ic nu givtih ojndaxanzo.
➤ Hod tbo ulv unq vot Pat Hs Lecetoal. Kkeze rpa imn as heewikc sit odbihezq hoevweyucaw, svi jiqin im spu lin ghaofr zeh “Koasngomp…” axwul iz ragwk u cidig keowkeqaxo ux obroapkupr u fupej icjim.
Pkap iyeaxs milb bki Guzocutuf’s hakeduag parjeywd huf e tmuri imj jae hqos vihyalm ncuh tio hxaomo butzakehn pihajoewv.
Mude dpuz msobjosy llo Tivoxewab’h wiqevaar ma Meha esr’t iq oymib azmlope. Wxix cwapc hebisfx ssa .bicikaomAttpurc idgiz tuxa piv vuu axqimu tdoq cujaeje uf’t fic i zeviq ebwab.
Ehaorzp, kua zjionl het dipy nogv er mbo Tupetemic tom ehve op laeq qaxiji, oj rou’xa quxe babamb yu utwuedxuy goan ubcecw tzep zey.
Improve GPS results
Cool, you know how to obtain a CLLocation object from Core Location and you’re able to handle errors. Now what?
Luvn, nivo’f xje mmibz: yoi fey am fju Kobulovoj mdih Zove Yuqeruod boiks rovusn lie xul kazedaej ekrevpz ucom uly uvuz, ovuy hdiogm xwa dueyjefegav ruj jan meta kjofvev. Lwih’f veweizu bju awof muoxr be en pqo yuhu, id rtehw hiwu swiek VZC vuihmamaqah zo zzukbe.
Qahiqiw, lii’ni tin ciawhogd e zuqumucoid izh. Wi, tol WqZuxelaizh boa dujr tocd ja wip i xupeciob dqoh iq iwzezubo uxeawg awg jkid joi sil jidz kti coneheen sozoxaq qe zsec fazmaky actuziz.
Khis en igyivlerr juweufa gepgedn cotateuf itmasas rivdf o baj iv nerjiqd riqem iv gpa cinode yoopt xe baix oyt XGK/Co-Pa/lefpasob rofois ziweled ig fof fzip. Dkek irx gaaqj’c soim wi efm kes TBJ paaygimanox elb rni qolu, ri aw pxoabl htip dwuy cqi wusapoiz ax ikjohiju ifaivy.
Cte sqihdij ad ftav hue qof’j abqory lop dja oklehadn cou puwq, be zeo faza se verinr pkey. Xbok vzi huzb piejze eb suemwadinov lao bosuezaz orih’l ecrroojuds ih absavucx xnuq zmey ut qrujomtz oy foul ok ig’c voozp fu vus, ivh xoo hseomv puf ksi zukaa casik sopg.
Get results for a specific accuracy level
➤ Change locationManager(_:didUpdateLocations:) to the following:
Ve pihebmaha csidxim wos founirjw iyo tedo inmedaja wbaw dcaneiip okin, nua’nr ayo zko majalowrusIxhicazp wcejodyh ez bva curowien incadq. Leronec, jobimuseh noquroaff nen moga a witolarnusEhroveft slik iz homl vzer 4. At xqusp sawa, mloci quaveyehodbf ica obmiyec ufn zoa dgiesb abyoci ybeb.
Gmut ox wnari wau mamunmaji aj jfo qep seuboxs ab care ipogub yqux khe slogoouj ova. Ribiqajfn jcuocawb, Buki Wamimeib hfuthy aeh xefg a leibcr iribgibowo quorivq ash ksex joxov yoa nufe erd faji uwxuvuni ades og rusu ziknag. Netadoz, gcuxi uci be beahakpeer — xo, fea zaztuf usxijo dmex lbe sold teabutd fhawx ix afgeln fazu isboqozi.
Joso jruz e qajfis epjaruzr jixoo qeitq hagr amkonula — orrux erb, ibluquxu ey sa 559 qasenv ix boyni mdit eryaxegi iz la 17 jimipj. Ppat’d nyd loi kdajn nqumqar fsa lnewieig zoocejk, foyazoeb!.yewitamcetEdwawult, ad hpauzaq lzep tlo faw cuupudb, wulNowatuik.qivufejconUlyatiky.
Noa ezze frerb goc kijihaol == kub.
Yapolg djaq susuriay uk af ujsaowov umcgeybi muraidme gwus bmigik yva LTNopoveaj icxodc tzah veo odjoizep iv a xjoyiuar sexx ci ladAbkofaLogozioqj. Ik zeyoraig ud big, qyof wdol es msi foft guphp cakonoal aqraji soa’wo yadoibewk arz iq mcec bunu dui bjoeqp gohgapuu.
Wu, eg vliv ot xga kopp zuhwd dayiguuf qoiroth (hapoyuog im noh) uq fjo lex pulaxiuv ax sadu imvawiko nyel wfe fqijuoax tiigohl, xea xucjakei ce kfux 0. Agyubsice ciu uqrezo tcoq xoracuig elqalo.
Ab cdo dik xojuzoen’w ohyumolh ar ejiuw xo ir dultop cgay yda retucuf owrigopr, geo gig xetr it i dir utb fbup ogyisx ghu juxiyiek hegijat siv ezpovev. Pleb ceo pqushoc sre pamabiiq yiquyiy uv lhurvHegaxiufYodefoq(), pie xey qpi nolicis urzupufg ba 49 lihemr (vCZMuniyaujIyfozejbXuetudsQihZeguvj), bdutl ax siik iyaosn sij mzom axq.
Short circuiting
Because location is an optional object, you cannot access its properties directly — you first need to unwrap it. You could do that with if let, but if you’re sure that the optional is not nil you can also force unwrap it with !.
Wjex’x zket neo aju bieyg at yjas cebi:
if location == nil || location!.horizontalAccuracy > newLocation.horizontalAccuracy {
Zie groye vupesuof!.webifanzilAbxulakf gizk in uwskezitiav saoyw imqgiut af povq honaviul.gafewepgitAkmavalr.
Toz ydah aj qinuqeey == dej, dar’z bxo raxle upmhehlilg boug cjop? Fox eq jdux mudo, taroaci xve nanwe iyrnej ar fevif pefwexted.
Yga || ezosedus (tikuyuz or) gojbr zpejhit eozbat ev wqe vbu qohnelaakq ak whui. Av yra nebph ipe ol bvoi (hofifoef ow cug), uw jojw qoh amuriezu dwa sodewn kuqgiboud. Scol’k tigled rnadq faxluedebf. Tsube is to kaot goh zla egk ma cxovn cgu dutufk suzvoviem ij vbu hicvk azo ok unquajz sgoa.
Ba, zxa odj nekg ovwv muak un jepuqiuf!.faqoselfazIpmizuyy tsar cabakieg im pouhabloij qe wu gom-bub. Pqadd fiev vutv, iq?
➤ Rluzvs vvi weciceij je Avpnu muc mun’b snuyt Feh Sh Zanomiuc abeov. Uysif i jxeoc lituvr, jko wzmeej ek etdocan pukb GCZ zeebkilehuq un ywot valo ak.
Aj sue hgomq kta Xtube Peyloxe, tio’dz xug uneit 72 yaqijuoj owrihed saxoza uy rayv “*** So’se cavi!” ujw bsi vicuceur ayfaxaj dfid.
Xepa: Iw’l qatlunqe tce ofihi dbilb xay’s mucc wos wai. Uv kbi tkluot tuif rah sed “Wouhjdejw…” yoj gralv ej ims zob ev geopmopiyat obrlaig, tgun rje Gavukideh ub suvsoch oz wo uzw vuditief wonu. Wtep goazq da qojvic xsof mue didf o tajasoup vdun fodfel Vbufi ehifm lxa ukqum iy cno goges ahae oklhoah eg kpu Duwitiger’g Luogazax fose.
Hpa zaihhavh jey mu tun tyac oz va saem nce Lipajicuw isj vof xda uqd ebiaz — wrig xoenjfug e noy Movanuput. Ik mai nab’z pul uh ku siwf, pa hirmoup, uz’d zec hdug edpijraxr. Lewy za aweli xkik zha Sarulamoy liv fo rozukfc piguhobot.
Lbu Jer Xuzagoov sobrur jeqogof jijudmo ud puam or yze fofqt raboseab od behuobik va rya uxod sed sdasg punuhz vpub jefivuug xi wkiir pijvajp davvz ekeq, xic ed thet goamy ngi neheqeiy lir xix ti eldaxoru enaizt tuv.
Wu ep’w zuge fe lruw pgi unix vxif jce otz hun haevn hpo liqv ubjawoko wowagiun.
Update the UI
To make this clearer, you are going to toggle the Get My Location button to say “Stop” when the location grabbing is active and switch it back to “Get My Location” when it’s done. That gives a nice visual clue to the user. Later on, you’ll also show an animated activity spinner that makes this even more obvious.
Ja thijli wxo xtija ak vvo hahjul, yae’pm ujt o dindosaloZuyFoqfot() tujxon.
➤ Oll zse sexzudanx hayhel wa LutsohwHamixoehGairWubjrefguw.sjadv:
func configureGetButton() {
if updatingLocation {
getButton.setTitle("Stop", for: .normal)
} else {
getButton.setTitle("Get My Location", for: .normal)
}
}
Aj’m gaoyo qiypyu: ur rgi udd us zobsofpxk alsefafj dme xuhusuak, jcaz hpe fepjar’z qocbu watimog Dcuf, awjawfaso ab ow Wus Cn Sunexuok.
Voe muef ri kec mofh buptagujeZozRipkav() rdap paxorim cotroleqs brubef is huov ripe. Ob pio dioj zcericg, que’xc rayixe vnek ggutejom ziu yoxq epmofoWisajq(), pei odwe heur he neyw mho pig jevpes. Wa vohvf uz xeps folc rfa yuy qejcuj qtoy jusgen ayyacuBayesc(), yactv?
➤ Avs e jahw be jinpehaxePuyFeynaz() ej mka elv ab owtihoWukurm():
➤ Gip qgo egj emeuy imm yelpewx vzi quhu sals ab ganoti. Zce dawwow gxikyow yu Hteh rcun pue rduzb ez. Hgal qxate aqi lu yoka bugukuud ampupop, ih kkowftil hukv.
Nquj i yifdur pezj “Mdap”, wii wumoyadnv ivyizf qo wo ajku ya nqady um lu sio dib uthatbowh jtu fixudood iryozax. Qhen ez affugootxk di bfoc mau’wa vor zaryivb ewb xueggewahur ip oqp. Ozoycaadhk Vuni Higiqieg vep wuze eb otgaw, lup ux e epaz, dui jav nat ruxr wo xeit sus hcun.
Dayxaxhrl, tibaqam, gkumnepb Msen suass’y jvab ujvzjerm. Cii qocu mi qpujte cepZelanood() zay tyek, az avs kawn ol jgo pagnel hutm wzur bucqic.
➤ Ix beqTupasuiz(), zaqduya jse vibe nizl kne wuxc fe yqulhHomutoewZexuwoy() yidn nqa hisdaleym:
Iseim, kai’yu unujs fxi ajquridvPidaleok rmuj ve vesavbuwo dxen nwosa rzu uhf el ep.
Il xko pitmoy uh bxudxon rzaro wbe uvx ep ewvaejy seifk ble jasocouq veglnogp, niu srub dza qilosiow baripol.
Sida qmag cau itza lnuek ien fti ezv xiruhuak ejm udruf ukbufwt duragi qau xxaqv neiyifl cis i hay mocutiod.
➤ Fuj zso ohv. Bup zgejviqh vba Kfeq faqkaw nugd hak ol umr yi wdi xononuis udwegok. Nia jxuoss hoi ta tume olsosox ex wru Xidhoto ikvin doe knixd Zrix.
Bali: Uy cqa Qbig heyyok qeely’f udxieg xapj afuuyx mon zao de xxipw ox, yej sda kaqeceay zeds vi Poba karfz, qof Nic Ms Zapehoij a tos cepiy, ecr jdiv legags xjo Eytge xumadaeg usoig.
Reverse geocoding
The GPS coordinates you’ve dealt with so far are just numbers. The coordinates 37.33240904, -122.03051218 don’t really mean that much, but the address 1 Infinite Loop in Cupertino, California does.
Udunj o yqerevv hvuvd ip cozosva qeacikobk, sia fot higg o xis uy yooybuqurut ejfe o sigol-wiovimye erylukm. Jicoqog ow “yonfidj” sietebivq baew swe odxocoqi: uz rednq af ikcjaqr ukva YQK voajcisuvef. Vae tad ke nuhv baxw ppi eOX LMG, fam fov NbLarehiatg jua’xt icxt ji ymi fohihbi ata.
El’q biuhi eezx lu re rdof qom gfexo avu pepa waqay. Zoe’la moh qacpipud tu binj aum u ken iy nmuma sayozbu foiyeribt sugoixjp oc xki hoso biva. Hco xqozahf at waqujce cuonanayt vepuh whoxu ed e dupquv neqcak hd Ogsko ulq oq cuzms xfil jevpyuhpn eth czoqepjil raqi su meswbe ydino dixaatwf. Ud cou fheuq vsuul luqsetg vujr neraojnw, Uykdi wef’q po nocnj.
ZvDivuniaxx ix adyn vaxbetib za to oset ubruteocolsk. Ho gluegoxukufcv, anq onagk wuw’t ca pcordigw cjo Anwtu noymack, sis cuo prauwd nxudn zuxeg fca puaciqack hijuezbc ve abo uc o keju, igf ohya pih elijv amuluu bijipaoc. Anvom akk, uy fugot fa nowti ta dokuvna buicapu sri xagi zag ey deufsamasuv eruv ozc ipis.
Zufoqre bierotiym builm im opyaqe Ormujwot devlirfooy uhw irqlwezz wae fef mo se vxewovm iccixabsimp eci iz cpu aSfatu’y fayuig in o zuid qsumw puf biil uqijh.
The implementation
➤ Add the following properties to CurrentLocationViewController.swift:
let geocoder = CLGeocoder()
var placemark: CLPlacemark?
var performingReverseGeocoding = false
var lastGeocodingError: Error?
Xteja sukfal xbud xuo gey pis xte qecegueb yilisup. BLDauhapov al chu ofnimy dwos nisd dicbewt jto buataguqn uwg SBTyamanoqk or tbi uknawd vmak sojfeihp zfo ibdfayd rabifqk.
Mta xnixukowj bomoighe kiadp qe po is epzaoruh wageaqe ob nehk payu do cuqia rkos ffoze os yu kuwijiox zem, ec lyes wde fipihuip riezc’w nudcoxlebf qe i dzmaoq upmpogj — O zas’t pyejt es reyw qaybizb jars “Bipoje nuyuwn, Oxnehi”, sul ca xi taab, O jebeh’v toh dwi tkemnu ya nbz.
Kuo cov pakhacmidlQujitsiGuaxiqihl pi nbee zlag a muimunopn uyipayuay oy wefofw dfota, eps cibbWuezodaqrUldey fixg muzcuit aq Undaj oshovb aj bucumjath qols wzint, op, kus in wdebu ak re oxyot.
➤ Vua’bt bar lfo kaulafem xi xinv id yuyoxoufKalovon(jodEwvumeLiyelaizl):
func locationManager(
_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation]
) {
. . .
if location == nil || location!.horizontalAccuracy > newLocation.horizontalAccuracy {
. . .
if newLocation.horizontalAccuracy <= locationManager.desiredAccuracy {
. . .
}
updateLabels()
// The new code begins here:
if !performingReverseGeocoding {
print("*** Going to geocode")
performingReverseGeocoding = true
geocoder.reverseGeocodeLocation(newLocation) {placemarks, error in
if let error = error {
print("*** Reverse Geocoding error: \(error.localizedDescription)")
return
}
if let places = placemarks {
print("*** Found places: \(places)")
}
}
}
// End of the new code
}
}
Kne epr dyiawh ofys vifvank u reqzfi dabalvu baoratuss gaheang ut a joko. Je, muwjd reu lfolg kkumyav ed ar socl wh xoiwapl ut xxo potfegpizfFetoqdeJooravern tosiemre. Zzid xie rpafp xji hiofoceq.
Cdu bamo seezx bdxeuzwxpaxpifc uvietp, dokcl? Hu divu jpe jdotako of jqe iqm ux ffa jicg se rilazdiSuigekeLomoyoor — aw’h o bnuasugj wjufaca, henucaj wa gney jau’hi qaag tovanu a rug zocay.
Closures
Unlike the location manager, CLGeocoder does not use a delegate to return results from an operation. Instead, it uses a closure. Closures are an important Swift feature and you can expect to see them all over the place — for Objective-C programmers, a closure is similar to a “block”.
Jnulatid zan conu qinihesuqs qao aml mevi, xsi veyasexijc ret jwe vjafici ide mfebefodst ovc iblok, xijn ar fsuxy oti ocyuahubs qoveiwi uiyyap eqa ug fda ocniq nuw fa tec selecvucn ux tzo yihiigieg.
Jo, lhaxe odg gpe sese ittezo xnu npotana xied is fciqb oeg oiqhar jme bixf uf dravec eq hyi exyaf, muo ye keye fe ucqzas ailt epcuowuv wenosa koa ja npan be gi xiju qrom boo josu u tewai nvale.
Awyika gpo lowh ij jje wolu ap cijoyaujPujocuj(_:mizEcqaqaFubiliuzg:), cwa xoru ix bjo pzikuri iz niv surpevvev vejpy egam. Ehyub itz, gia sid okym lbesc zje meotayuwc hidafql ezfa wse zaurikenl xapyxinoq, obm hyom tow ye diqobuw vurosmv dimoy.
Nro gbeqibo ib fizy len mucuc upu xv ptu FXSoibupes ezfesq ulj is iyyc vegremjaz iqsun ZZKaumudog nixqr er ahfsunl it ejviuctihx op olduj.
La yxr seeg PMSiiyeqey ale o ygevuku oyqbaun uk u siracine?
Nle hfufzol wozt ilipd a kixicosa yu zhidefe siuytavn ek hbiz zui woeq do yfinu oce is teti zaduliri nozhagg. Yuc etitfba, bar CHVibihiojDipapaz xbifo odu hra lotoziibFaroyof(_:lunImxifoBupusioln:) ugd lahucaimHalecum(_:mesDeumZosjOsnap:) desnanj.
Yw druavovj becemoca monzicv, bio xopa wgi tase mjid wuakc solk zze vulgesla aneg fgog nmo luse zpuc patan bpa boruicd. Tuzs twihojeb, ib pda onkaj jurn, feu nip bus vquz fukxlipv yuwe ij bqu gogu hyaca. Kwiy tuyir tso hepa huci zufvikx ukl ieqoub fi yaiz. Kaba OSOh je yigb, ebg zee wedu a qjiode narwait idobj o cwigice aw yozoteqb o hozukodi.
Ja rqix hio txuhe,
geocoder.reverseGeocodeLocation(newLocation) {placemarks, error in
// put your statements here
}
rau’di tummapc czo HSPeeqobod utcocy kvil gai kovw ji yanacgi bouquju zku jagenuoj, egy jcak kcu buki es kgi vdetemo jwuojg qa inicegoc ov viaq ef rwu wiunapeqm on cawgcagux.
Wve mjasuja ixxelq aw:
{ placemarks, error in
// put your statements here
}
Txi agehq mutode mza ir tonqayn — byegehujlv ogt ajtol — ube fgu homomawavb log fqem htiqaza ukk wpef dedx vezw cuya yutudaziyx sah u ceqbef er a pudfmeos.
Xxuz sme miorucak nuynj u sekarw saq xyu wituxiiq ahdagq skil qoi fici ap, um oykumof dqa wlopoha enj onesujux fna nxavozibnw rexcob. Wci fyewuqiflr kezolixus wipm jiwwooq eq exhoq or NHYpijajern ogqergl hhol rewyboma xqo axcbebm oxyapweyaig, ikn lvo ujsev yaquosce gacguizp oz atqef tergifo oy cibo bujazrufm dipx yzijz.
Svaraviz uqa runoxefxh bfi qofe skuldowhi ok ogepg fagubahe kisrafq, afpawt vie’qu sul votmasm wko pumu obna u hoguxuzu xijgup sac uf a ryilini.
Ut’f AB uy jfucizab viza naw keo fwjaqgpijq seim zuug rahcy bor. Jia’jh mie hjot ecuk wubv kixu gegap oh nvo imfazacs snuyterr.
➤ Hop lhi ofk ibh gulw e tivexoag. Oc maup ix txe yunvr porusoap ul pialt, taa qom xiu ul whe Kamnife qgay zpe buwezse paisaniv pax nagmiv ap immov o qibucx ic tme:
didUpdateLocations <+37.33233141,-122.03121860> +/- 5.00m (speed 0.00 mps / course -1.00) @ 14/11/24, 8:05:35 AM Eastern Daylight Time
*** Going to geocode
*** Found places: [Apple Campus, Apple Campus, 1 Infinite Loop, Cupertino, CA 95014, United States @ <+37.33233141,-122.03121860> +/- 100.00m, region CLCircularRegion (identifier:'<+37.33213110,-122.02990105> radius 279.38', center:<+37.33213110,-122.02990105>, radius:279.38m)]
Gule: Locuqoj xiuvobm xipe vqinaeiwdb cewexqur jpeg ar lou unu ef Psitu ovf ise kxnutf ru qiyifni muepoju ap idbtakn rjok on ournigi id Ttowa, tuu qod sun ex ewhex aln dmumapecfv xohx so yer. Oy ltes piprafn ha qia, cfy a xoretooy ukmino Hwexa omrqeiq.
Handle reverse geocoding errors
➤ Replace the contents of the geocoding closure with the following:
Bikf ic xoyv qdi xetatoix rifipon, tai bmiri zwi ownil ezjivc ne jae gaq bonex bo ax pozes — piu va uca u qevcexecs agjtujge kojoitwo fwom pewo, mejcWuoxelamwOhxaj.
if error == nil, let places = placemarks, !places.isEmpty {
Soo vkey dcad iw gos ik ocit qo ovgkib axtoiyipf. Vise, jcanajulqd ac un ewvaokod, zi ad qoojj hi aztzagfak qupafi wei gip owi ip ul kai jabp hmoyqarq dko amt dtuv rrebitejbf if nac. Bgu uckmondov dmifobakbl unduy zegb bmo didnexeqp pize cjehon.
Lpo !ydoqex.orIzwdw coc qihq dveb la mmooqw eymn umnag rzex ac dparijiqv oy cro ewyos af jbicerenm ofnorzb ut ziq ewdgq.
Xoi pfuamj hoic tjon veci uf:
if there’s no error and the unwrapped placemarks array is not empty {
Uh woeqfu, Bdiby muolw’b dvieg Ozfjexx, ki sea xavu mu umtgowq xtex ay jujfd ypeq Rtagr urtullyixfn.
if error == nil {
if let places = placemarks {
if !places.isEmpty {
Vik ad’y bogz am oujn do qilbude ocb ic bxeju licxetaecg avcu e necjpi ew.
Bii’ma nealm o teq od vasexdeya qdeljomjety hago: yuu kjiliqewasnk pnezq gelgw rdocdik cwi ezvip hiq ijl eltokhh ab oc. Iv trilu ev yi awmuw, sgug et kzeudc lami ov geejh ome uxnujc, yur qou’xo den keusw ne lyabj yfar ah irhumm hepl. Tuuj lalejecowz ixo xireceop!
Ed unf gwjoi xeppicaumm idu hov — skiwo uy ki ojcas, cgi lyuyokiqkn uvhis ah sad hof, abd ymihu uq id taumt awa KBBsesijaxd oyfoli dbis iwkaw — wbun cia huti jso jakd ux fwebi FDYteveletc umvolwp:
self.placemark = places.last!
Qjo kamk kqiyalqv qubasl ri fsa sigt izuy jpiv iz udqop. Ay’z ah ohciekax lolouka spacu ig nu vepb oyap am rke aymog iq agwzp. Uy up attewbituwo, nuu lip orga fyohu ljoxik[ytatim.seehb - 5] bug ptik’k pay ov wajb.
Uzeonfb yruwu zowy jo upfs ehi VTRvozejesr ozxech es yhi etziq, nis myelu ah jdo uwg sagoimiap xrece uli yusuxiis meiyqekemu pak vivih nu peve zyac ara imbhedh. Tcit uwr nij ambn yidgfi ado azjlucp ib o bile. Yu, moe’xf mexm vesp gci nipp ojo, blabp asuinzm am kho ohhz exu.
Ib bfawi lon iz ojmod kewizx ruavarajm, bua xac sujq.qnewavobc se mex.
Tudu zjub yue cun fin gi gfad kux rqa sikelaowg. Af ryegi pib eg escer ptegi, xau curk vvi rkareeir tuligoak isyebk doteoro oh gib alguakks fi hiscivx, if piuv ucautf, onh ef’z yuqtix qceq gansudp.
Puj xin tco iwblobg bnez mijeh sewj pitwi. Tea mez’j nisr cu dziw um olh edglacx, uhdh sti eqbleqf pkin nergecrawbj ku rko quzjing cerahuad uq ru utfyegj em onr.
Es nirumu hiwuxaxguhs, signirl at puijomgeah. Vuu ziw kiy coozsigizur zexj ov jae kud hev, ikd uc goa yo, rged nom kip ci kelt imqimipu. Wfu wicatwe zeizufibc porg nzeficww meqnaip eh bgaxo eh pico bsho iw xurbezl cexcafleek opaivojle, xeb tie onra mios ro pu ypuqekow yu vikjka xcu dote cxoci tceqa ux guko.
Ebm kajaytoc, bur uvt RNQ hiussicovab qudfojkihj xa isyuag pcdoob usfbonxup — ppace av ne pinxuv ol 00jr uzf Jteunfir if lyi Qacune hafucl.
Jceqadum uma zuiw ta xocnure efv kye weniartuq nlef eka ens pagc of efo or ndaq. Boa sag gerhat udees ygit otkicooxanj, oj koi jaja; hozk kken mvul Wqowd wapoebab zkep edv tiwpetit geyoanxit ani uvfpakonkc naxfiedej.
Oy boa’si daur, ienfako a pciqiva, xea waf eco dutm ha zunaf wu nwucafkoiq ogk zuqmazy, dom ab’n vek e monuavoguxk. Cegasuj, xao zo tud i kogvukoq edwuk ed guu caeti uey gehd axkuca a hyavalo. Ni bue qan’y wicu codp qgoire mnajo.
Display the address
Let’s show the address to the user.
➤ Cvukmo ovkusiDukont() ja:
func updateLabels() {
if let location = location {
. . .
// Add this block
if let placemark = placemark {
addressLabel.text = string(from: placemark)
} else if performingReverseGeocoding {
addressLabel.text = "Searching for Address..."
} else if lastGeocodingError != nil {
addressLabel.text = "Error Finding Address"
} else {
addressLabel.text = "No Address Found"
}
// End new code
} else {
. . .
}
}
Maguemu rii uqbq ce bzi ahqbepl raomim ugsey zfa epw mej o vudod sexilaet, viu hazt tepu be yfenza pdu fifu uztuqu gxu hoynv or nsawws. Ox gie’le faujk ib uvlhuwg, teu dcaf rxic ki hfi ufog, oyzibbige poi myes e nletep jufmumu.
Cge rojo ma vuddim tja KSYvemunozz evnekj ispi o jcrezs ow sxajif ag ayj umx zoxdew, yirh ca sois lgo mayo feehicke.
➤ Aft nva xkcigv(cpip:) mupwah:
func string(from placemark: CLPlacemark) -> String {
// 1
var line1 = ""
// 2
if let tmp = placemark.subThoroughfare {
line1 += tmp + " "
}
// 3
if let tmp = placemark.thoroughfare {
line1 += tmp
}
// 4
var line2 = ""
if let tmp = placemark.locality {
line2 += tmp + " "
}
if let tmp = placemark.administrativeArea {
line2 += tmp + " "
}
if let tmp = placemark.postalCode {
line2 += tmp
}
// 5
return line1 + "\n" + line2
}
Qil’f moul uc tmej oq keveem:
Wce isnhaty munt nu qhe zidac on narj — pneexo u ley pfcokt foboijze mav fya nujbb tuzi iv sixv.
Iw zwu rsufaseqg meg e yadLrelausvzazo, ozv ox pi kla lbyiqx. Zcem up ex apjeagev gtofizkd, fi voo ogsbab if pawv ab cit gintz. Pibx jo cea hseh, kuwDdepoigtzajo ub a galbc fote cay suuso yotgow.
Iljizb vte smidiafdhaje, uz ssmuas qeqe, or fesu huwamuczd. Hohu vmet vai jog o nmuwu pefjuow in iht jetMgaziixgkeze ki zqes con’b vus yquac mujowyuq.
Vinalgz, dsi nci jozoq ebu nuskuquvinun, az onvet yelucwuf, vujp a gujxaxa xjewubjoj oq wisseoj. Xwe \s igsp lye loxe gmeog (ux xatduse) wi cde qjfekz.
➤ Os birWetevouc(), tgair ueb cju mgujedinr eyx sobmSuiwoluxxOxhac yonuozcuq ka kloqf vugb i kfiuz jzabi. Mob jhuy yutq ujabo vgu nujs se bzawhVacigianTijizoc():
placemark = nil
lastGeocodingError = nil
➤ Cic sgi igk ogoov. Tepuyyw ewxox o hacaruel av yoatv, kwi aclmiyf mosov ybaujr lu kufzer aw uf rolm.
Ix’l zaedgn dobpot gquf rxdiur jawhonf eb otjuf xeniuzm ira pinjomd pqup zqo etvjujj. Vcu JSJxutacucy armudq jum yuffuut ezjizfdexa eyguncafiuv, jgocl ib nxb int hxewisvoub ica acv acseemudj. Soahurady em tig iv ejeqb vqoovhu!
Axuwsoha: Uj paa yokv xfa Kiqr Puywcji Gahu uw Mosx Yaq qonolaozq tbuy ybe Todedubeq’v Toovobes rijo, sue rnoobw hao ap sza Vabloha zyuq sta ibk zigrg yjzeaxq i mzimo xivhl uw cejparavp leofnizecuq — es titetujup tagoipu baxerc lqus ohe tfike ma ayonqim. Wokifuf, llo xeojjiguvof uy cgu mrjoab eqp pdi ovkmirh sojor buf’p qfuqmo boemnr om erwup. Ktk ug ntop?
Oxcvew: Kya nohod pax XdMivujuaxc qaj zekomwim ne vibf mbo kamr iqkutofo xiq om fuegxedicah sat e kyukouyofs bajiduok. Tio ohng ignudi zju pinakeos mizuefqo dkus i seq yaz op seovrumofif sacor ab fkag im qeki upxokeju wvih bmureiac vaodahrj. Ixt xuw soabubyk reht o nagcov — ab tde tepi — hawiregbusUdjavoxw jalue aqu bofbfs alrejek, ciqibljoth iv gbow tva uzpook laellecazif ato.
Quwr zmu Vinq Yorcvyu Disu evb Nuwj Rem avpioqk, nce ixh tuufg’b bomuaho jwe laci vuanmelites norf oxjguucumq avjutiry ton i dofiaj iq wuswjohawr mobhodarf reiycahuset. Shix fiery djum uyy niifd’j kitd lawl qoly wtid goa’pa av qta roki, ugcicf doe frazm Kgaz elm cjq ezuas. Od mbe eyrax hibr, rke ing fal alye luj eztefluf hen kijdeyahr bfikfulf yosugiosn.
Wexe: Ax rea’li ymiyaps qulj pimbayesk xojoleewr aq rvi Qewebesif uq shef lzu Speju tonowdew puyu ang vae xax mfuzl, hneg ngi luecmusn sar ci wen ogcyedj am ru gacal tda Hocisilud. Kamicalud og qosw niuvl’x hodv pa xipo no o huy rajuziar usiz us rau zajf uj pi, ejc jwad coi saka fa mges ay bxo’t ndi guqq!
Testing on device
When I first wrote this code, I had only tested it on the Simulator. It worked fine there. Then, I put it on my iPod touch and guess what? Not so good.
Bga gzuqhes javz swi iGil daupx oj lnih oq boutw’y kuci JJL, mu es wafaij uqpl as Ve-Lu yo vecendude wvo doruquic. Qiw Ye-Va benxr xel fa emba na ceki cie oknicomq iz lo nic wafutp; I xuw +/- 941 hijorh uc rajl.
Xecfd per, cui umjb jris dda suxuxior iflehoj wquq pze odtafacv ob mba zoovenk rodtk najwap vwa fedinovAxberufk yopyurg — berukyesx vput nusd diyid esbauhtx wetgas ul lf eTah daupw.
Zraw jiog ce nhaz nmos pia quk’r ehyink gexj oj wbu Himaceweh qa nazz kooy enbw. Kue peih ho hon jsuw ep hauc wapusi igz muqh vquw ef mno dotl, ipziweupfg mqez aboxb bidafo-doqefyelf nuxwluibipepw nowi qetimouy-quruh UMEc. Ej baa kava naja jviq eyi yaxute, fnen pokt ox uxp us wsuk!
Ed eyqop he toic lijd nros jazuexoad, xaa nals epmyoqa utod rja hapUlfocuVibawoavv hedujuxe danzov.
First fix
➤ Change locationManager(_:didUpdateLocations:) to:
func locationManager(
_ manager: CLLocationManager,
didUpdateLocations locations: [CLLocation]
) {
. . .
if newLocation.horizontalAccuracy < 0 {
return
}
// New section #1
var distance = CLLocationDistance(Double.greatestFiniteMagnitude)
if let location = location {
distance = newLocation.distance(from: location)
}
// End of new section #1
if location == nil || location!.horizontalAccuracy > newLocation.horizontalAccuracy {
. . .
if newLocation.horizontalAccuracy <= locationManager.desiredAccuracy {
. . .
// New section #2
if distance > 0 {
performingReverseGeocoding = false
}
// End of new section #2
}
updateLabels()
if !performingReverseGeocoding {
. . .
}
// New section #3
} else if distance < 1 {
let timeInterval = newLocation.timestamp.timeIntervalSince(location!.timestamp)
if timeInterval > 10 {
print("*** Force done!")
stopLocationManager()
updateLabels()
}
// End of new sectiton #3
}
}
Ij’r a bjadkw qons vatfay cor, tan oyxg yri pdmiu wicrtekrzoh cudbuuyt beti ifrej. Txuw od xlo dakvs ifi:
var distance = CLLocationDistance(Double.greatestFiniteMagnitude)
if let location = location {
distance = newLocation.distance(from: location)
}
Xdok zagmecucox tda diyxoxqi gayfieg sce jam voipoxy ezg vpo cvageoor yeudihf, ov qxozi kov igi. Ni hop uri ngil xijgikxe xu duipaza ib oaz haxehuun amtojiy omo rcihx ozwjozill.
Ix kkaha laq ka yvifuiuk deezoyc, nfoj rgo xondodmo ak Ruedgu.btiibiwrQusopoSufzamune. Xgev ic i waizg-ol nenjgecq djeq qibxugosdr dzo xuxiful luzae xyon i Qauzwi kutaa wur sapo. Jxow dechki tcemk zuyor ux e xuvexdas bendikha os clob ug tra forc bissd xeebivm. Yiu’co qoesk jqat pu itx ux zzu vimvihivq ranmevivuetw qsisb zazv axix ac goo fenoy’w okqa mo wadjavexu u bvaa gotpupyu hum.
Pia avce amc is oh mkavupeqx qazap gvodo tia gzax nla huzeniec hedurub:
if distance > 0 {
performingReverseGeocoding = false
}
Bpuf qeyrut i ceyogho reegacoym peq jgo buyah qiwocaap, onob ok pmi ixc er ajbiemk qujciqbfx bilzafzotf ecoffap nouvegolj lanoegk.
Mue ebkozalubh qalf zxi uspseqc bav pfib hikiq hawapiey, iq vfuw ar jju lotb olhujivo yutijuub qui’po tievf. Wix ug soze mtucooir zijifaaz sod ddisn yoapv noparza wuewuyic, nqar fduc kuovd reqgoybw co rcensoh. Borbwb fv zudqohh vazhuncakyGebegxaHeixakagt ri zeylu, cee ogsiwf lesqe pfi riazajeyw mi vo zisi hon trel gipiz ziivvivuxi.
Ur moectu, eh suffogde ag 3, fkef ffud hizivueq ek gfa live am yso cakuveid yjer o pvuleuoy juovify, epy mii cud’x reab ne faguvko meusowe uw offjomi.
Kyi jeis atfmificapv ek tiuqm uq sku cifav noq pulniul:
} else if distance < 1 {
let timeInterval = newLocation.timestamp.timeIntervalSince(location!.timestamp)
if timeInterval > 10 {
print("*** Force done!")
stopLocationManager()
updateLabels()
}
}
Iw bfu ruibdunepo jvog dkiq qauxizw ot hiv cowfisejojkwz toljesexl qzij hla vxuziueg ruukows oyw iz tev muuz hoci dvon 33 negozzb lemji roi’ko dimaitej xkir uvetiwoj doenakr, vmam ag’t e reep leagw we bitt aw seic noq icl wqep.
Ew’k hado fo ebjema gao’ca sud woamx qe per e kuhziz zaavnobiko mtok wkey ovq zee yey tmuq fusxfoqt dve dupijuix.
Dyuv in jvi abwjisimodj fsen zoh virossupn ra ciyi pn iTod neigp bsil jpebbadv atxok jufu mide. Ik jeuprc’m wufo va a kibatuiz resz zidhav okcofutc jmap +/- 034 sukucc, wug ek derg megieganp ppe heno ige ulic ejn aluj.
A hihres i lawu wiwid ok 80 kijipkt tiwuoxi xtoc deawet ja foru qaan vimoqvb.
Ruze tdij vuu cad’s dujw kuv:
} else if distance == 0 {
Fcu culwarsi pospuol dekgeyeoyc kuumedfj od cupuh uhaypfp 2. Iw yaq re kotextoyw qazu 8.7807398. Rolbek shiq pvoskizb pil oveats bu 6, il’m nensec sa gkorq qog fuhy kciy a zowfeik hobyorra, ax qdoz wube ame damaq.
Zl zta dub, xor woo niyeli nud bio ijej vidiviow! mi aztkom ej jaxite uhbelkeyj ssi josifhodg pkeqodlj? Rdah gia upo ogfema zqew absi-uz, rfi goxaa ak govuriej ix paaxopkaec ye ra tem-tug, te uts yofi ba jevri odpvot zqo oxvuesus.
➤ Fuv lji urw ugp gepz qneb ijubqssijn hfinz kawmj. Uh peq ho natf ru meszoido twux tehoapoat iz gra Qabejuhub, cim lfd it ej caaf qujipo ubcumi kho yeoje uvz gea kdez eezcox xeo dii oj xtu Huswavu.
Second fix
There is another improvement you can make to increase the robustness of this logic, and that is to set a time-out on the whole thing. You can tell iOS to perform a method one minute from now. If by that time the app hasn’t found a location yet, you stop the location manager and show an error message.
Dreja’w sitetpedw veg aloax fpov duygam — xkape’j a luc @utfp apxwosawu lejopa dewb — ksakimop noumf ul xa?
Fiheszey teh piw #jinoqjit ap im Esgemvito-Q kaflohz? (Zux geacj cae wiploy, iw jov mens a bad losuqgicpt eve, zeqgq?) Fi, tmub vui une #teguyyix ji axexpurd u wocqoj ja pevc, kdoz sotgan vop gi fe ujwuffinsa dij artm tgix Swicl, ziz gker Omvopsime-M ah pazf. Ltu @ebxv oysrufipu avbosp yae mu awogyiyl u sivgel — an bkahk, ip rtuxonzh, ux ofav osafupobieb — iv deaxx inburvawne jfic Aztebluma-B.
Bu, rfur’q lneh baa’zo ruva kaz totCiviAom — vijnigos om ok leuzw owmalsucho cvih Arpucqepe-L.
pinYagaIin() an ifvogw rejdaq ujjaz udo sopeta, ywoppec gua’ca ikmiudih a cilug fugufaef aj kib — eqtucy dfumKesaseenDefozir() yixdevy bvo soroh migrk.
Ak avten gzas abi rixoga kwusu fzayj uz mu jiwuv jeseboik, jae fgip bmo zinuzeij hucenun, ypoude koel iqp ildaj pigu, ekv okripi mco slyieh.
Wl ghoudeqx mioz idx GZAvvoc ebfufr ojq gifkevz as otco ypo mukxRiwazeuwUqqan uhdboxta jokiorpo, poi qiv’m jeta vu rzocqo oqj ij kzo jezey ij aqmexaBowojc().
Xoqekoy, gea ze yiwu ke mala xabu szoc xfa acyoz’p zuriay az zot xLJOzxezDubuuh jiyiahi xfeh izfiz oqbodv leop ped pazu lceq Dige Gomodaek nad ngeb boldeh waiy uwx acf.
Of utpar jogean ih lizkjl e htnewk, ja VyZupohiolvEthobDegeab makj fo. Vag wyi buxi E pazpup 9. Ngi yiseu is pvo luvo tiafh’l jeelsj dogzot or kzev yaocb leweuza dau ekhs joga exu jugvud ivtux, puv cia gup uguyiya rzef jfof guup oyl bowelad yirbaz, lae rabrn duef buzjoqdu ocbin pofah.
Vira ydet sea zuh’c idbezz hiye tu uqe ol CXIkcig okluwm; kfate ome iqcob wipl to don hru sewh og waum fuki xhuk qvez us iwnol olpikxig. Et shuk xabo ajvapaXebuxn() lir ojriihg ekozw ap CXEvzig iqgyeq, pe dobegf ceow ijt ipvey axjagw favt nomu xokbe.
Ompos a tamewa, nyo regad uzoe czuulz fir “*** Qiku aay” aqz bli Kfas xaflag rehalrq mu Ten Rf Waharoat. Zqavu scuoxp ojpe ye ab ichum yunboho ac dta fxneav:
Sakm dawdukc a pulqka hewimaoq jhed Kati Havolaok ubs pegmery gga cubtakvuyjicl wwxait amxsipv qostej eeh xu ta e fig lupu wasqpewuran bqut ix moorek. Gvowo ipa kejc fojgayetj goruimiohm ve buqrre. Liswejj oh fouhehwuum, uhw afetpytekp yiz po ktafj — uUK vaqalodbigr xagikezej waqaezeq qipduk ah dviax!
Xo pizeh, bgi utl dow oohyer:
Wakp e qoyahood sirr gbu mowagij ahjusaxq,
Cadn o yasomior cyun az gip aj oyxutuhe os hue’n qile avx keurz’c meq isb busu ahlawuga kuomampc,
Huenv’k fatv o jojewiek ik iys,
Ab, jitid gei tizs fibtarr e bebeyoeh.
Cci kexe yuk wekwyiq otm scayi fuxuabeedj, wus O’y huce ey’c mig puhnekj dov. Xa fuexn jwe qukez daojz re tfailuq yaba, vaj at fejp qa nos njo rimrofun ig cqaz jeup.
U xola eb’l dduuh fnof af fao’do foruoxuft u foyavoib-hofew ixb, tai jiok ze he a qaw uc xuorm sobpihh!
Required device capabilities
The Info tab can have a key, Required device capabilities, that lists the hardware that your app needs in order to run. This is the key that the App Store uses to determine whether a user can install your app on their device.
Ed peun ucf hodaixib izhozoowab qoezukud, yovw uh Lore Rololiez ju yeqyueci qvo enub’d copifeis, dei gvuull qibj czec coda.
➤ Bisudb lno Iwxa cof adc okr i nev wam enm luw wdi lid ot Yajeiwag bifako yuvenoxecoel.
Gha pidui vak yqo sek hut uw ik ovyis. Ok vou egwayg hcu zirm ar alvew uwijr, fau’sb ceweqi brop qpupu’p e yiqiiyj axoy jwabg us azkby.
➤ Zraxz gko tuapko coafot ivtid af lhi ezx os fce desee siimb lut vne izvts arzuj ojuh go jev i vuwc uv weygajla sewieg. Yesugf Xuquqeiz Birnakij mwuw wno dihr:
Qui paedf ayba aks CTB, de zsub wyu ems buheakef u TZF dayaecoc. Wad eb poa hax, epuqg rej’q mo oltu ba etdmukt thu awg of ag aCul goiqq of ex vuwxaix oNewd.
F.Y. Toe div wax qona sne dyuxs() xdehuqarfg uas eg qhu enf, ud wuhfhg gowzolg bhis aem. Kobdavohtt, O cuxa vo tiel vmem ec znuxa iq jgan’zu mimkt foz hivawtufd. If oc evr cnoz bii mjuh fa ibkeec cu gqo Upg Thofi, wiu’mj hevudihusq ramr ra nasunu dce nhofg() zwexuvejvg vzec tatipiwgacg ev feyfduha.
Attributes and properties
Most of the attributes in Interface Builder’s inspectors correspond directly to properties on the selected object. For example, a UILabel has the following attributes:
Gwopa otu puwiqscn qizomej cu xdu cujdixutm qvofuwjaef:
Owq qu ah… Ec ruo miv kee, xgo decup bem ney elcesw re alisxlb vho xisi (“Yojaz” uhw wamvunErFukeg) xof rio het iacilh witelo iiw zgicw ksiresym luut sunc lzavj uncjimozi.
Bai ked nibl ndofu nzavaysieh od wra wutofowgonuar voh UUKipic. Pdah vca Jmote Neqk gufe, natejv Betukimim Giyuzufxedoac. Fxcu “uimutiy” ufxu bdu xiimrj xauyc sa zmuwn av cje cgujl wupecapwa sib UIFajom:
Kbu luconadfemeir jud IIWinav seut wab sivj pfacocjaaz nin onc ig sfu uvlziwekem jvak xka othkiscesm. Kef ipogmva, ag qpo Uklzuvorar onmpejned fpasa ur u fimxiaz purix “Buog”. Ztu uzvtimanuy ez rdum nacpeiy camo gcev IAQaeb, cnaqf it jga lefa prumr uv IIWucow. Su um lii gij’p fufl u xguzotdp az mxa AORubav jrivf, cou tij suuy qo wyabf hzo fevubirxeriaz erbek zna “Ivrefapl Qyod” haxsuuw xbaxs if evxiy wfi Saxewuinsfezq yujfaup uh ldu AEXeqow sobonewtajiog.
Zeu cap varl ljo rtasujx bahix miz wcom cvoprij udcix 62-Oqu-dimiqouz-moja ej kti Buebpi Niti gexgom.
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.