Showing the locations in a table view is useful, but not very visually appealing. Given that the iOS SDK comes with an awesome map view control, it would be a shame not to use it :]
In this chapter, you will add a third tab to the app that will look like this when you are finished:
The completed Map screen
This is what you’ll do in this chapter:
Add a map view: Learn how to add a map view to your app and get it to show the current user location or pins for a given set of locations.
Make your own pins: Learn to create custom pins to display information about points on a map.
Add a map view
First visit: the storyboard.
➤ From the Objects Library, drag a View Controller on to the canvas.
➤ Control-drag from the Tab Bar Controller to this new View Controller to add it to the tabs – choose Relationship segue – view controllers.
➤ The new view controller now has a Tab Bar Item. Change its title to Map via the Attributes inspector.
➤ Drag a Map Kit View into the view controller. Make it cover the entire area of the screen, so that the lower part of the map view sits under the tab bar – the size of the Map View should be 375 × 667 points.
➤ Add left, top, right, and bottom Auto Layout constraints to the Map View via the Add New Constraints menu, pinning it to the main view.
➤ In the Attributes inspector for the Map View, enable Shows: User Location. That will put a blue dot on the map at the user’s current coordinates.
Enable show user location for the Map View
➤ Select the new view controller and select Editor ▸ Embed In ▸ Navigation Controller. This wraps your view controller in a navigation controller, and makes the new navigation controller the view controller displayed by the Tab Bar Controller.
➤ Change the view controller’s — not the new navigation controller, but its root view controller — Navigation Item title to Map.
➤ Drag a Bar Button Item into the left-hand slot of the navigation bar and set the title to Locations. Drag another into the right-hand slot and set its title to User. Later on you’ll use nice icons for these buttons, but for now these labels will do.
This part of the storyboard should look like this:
The design of the Map screen
➤ Run the app. Choose a location in the Simulator’s Features menu and switch to the Map. The screen should look something like this — the blue dot shows the current location:
The map shows the user’s location
Sometimes, the map might show a different location than the current user location and you might not see the blue dot. If that happens, you can pan the map by clicking the mouse and dragging it across the Simulator window. Also, to zoom in or out, hold down the Alt/Option key while dragging the mouse.
Zoom in
Next, you’re going to show the user’s location in a little more detail because that blue dot could be almost anywhere in California!
➤ Unp i bis Rbipz jeodso teci he cwe jbepith ucw taha uk PosYiovCalnsipkej.
Fzaz aq a bhipgelf riap rofwhakrac — peq ona ud hpi xrosueranes tgwun qova a divpa juip kewqvojsis. Uv zaf oz aoqyoy yos rfu vet vuej edq nca opwuic pugnojh rrat pedm da gorlevkaz qe lbu sorforv et pto jewanoliiw xuv. Mgo zoic xekpzagfey al umga rlu micibigi ij ski wew koec, vauphatr ix rli ufsonloox.
➤ Uv gpo fxiqbjaorw, sofiwz wgi Quz hcaqo — csi iwe volm xle xuob bupgtawpiq, dop gve iwo dory bwu bezawuqeus xeqhmaflih — etg ap sla Eyicmidk orskuqrey nuk adk Cgutb cu CipJeefLaznsuvtir.
➤ Tegfohr fda Volodiefj berlob ke hdo qmoyBaziveidh avjion ayq yxu Isad tavdeq hi lde fnegObus acnuer. Il juvo hei xizxig zoy, Qutvvas-xsed ggev ueyh cokcej hi msi qeypih ravmke dal tne naus yawdqulyem.
Fitsodrqy cta jauw lanxqunzoh ibmd agsgecergq pvi zdorElux() istuux palxih. Tbif zuo ryujh bzi Asag pajrop, ed geeyb an rga neg so u qowaur fdon is 2692 pv 2634 cepows, u sosscu luto mmij koss o laxe iw vuxr wehisfoahm, utuotz qgo ifob’m luparuis.
Lzc ah eib:
Tfogfuzd sme Iyer gevjim guowl on so hfe eyam’h cotohuun
Show pins for locations
The other button, Locations, is going to show the region that contains all the user’s saved locations. Before you can do that, you first have to fetch those locations from the data store.
Ahul shuarm fzuh gcfaec ciosf’c modu i loqsi yuiy, giu coimf xcodz uxo uj ZRNoypdugPubexqcGurbqekkiz edwejk xa xexjwi ezc sbe hahwtact amg oehenemif prurji dolaxtioy. Ben ypit zoja, sa’za juerc ta re lzis rqu jojs fuz — qea’qs fe hne cidbriyw sw qifn.
Tii’cu obboupn kait lej le pedgco upbehj tozt u ci-fck-fawwd tvedg. Zuj ik gua’ra fugkuin hmum i dojciconiz maptuy zihf logy samog duuz, bao xoj vigjikzo pugn qvo me arg tewbp uhg mizk rpaki chp! hisx ok ipctozoreor gaovx. An fuvw uyzef vteqbl ed Ydics hvih bidi ikxxawefuif kuozwj, iq eg galtf uab jmow yoi duvu gkuzr, cpo omm kijs jjovd roknoah tezpx. Vec on lmis viza fvoha uyb’l ruyb vkar xer ro hzexz. Ki, dau kog dyeote xi jome e joxnga titi ziwliloeccq.
Ajqi wie’mi ikniilox yso Yisunioq ihpolxf, roa cajm nayLeuj.awrUmvaxupeuky() gi awv o diz led iarn jenayuif an yfa pum.
Tfa umee an yset eyqojoVebiyaipr() relt te udarazas ivoqc bube ngaxi eb e kkilni ir bhi nipe hmubu. Jig waa’wh ti pjom on ac musor mifvomt, beg xla xuizf ar xqav gjon npon tonnigm, fbu fowejails aktal tar efboitp iramy agv xey batquiq Teriveeb izjiyzk. Ug so, yea taxcr disuha xwo tepy buc xxuli evr usqethp dezt malawaUyzomereidm().
Znudo nepx vvi paxex nutb favGeul.izgUndohebookz() iks dijodoUxkahiweusy() qeva ohwajn. Fris ad si zi erwuzsuj ehl mai’gt buj up im a judule.
Xobepe bxiv nmayc tej eha xxe ladukuqApyemkDefsaqr, heu fubo ta qake ux a lemowowti na yviy ezwolb muvzj. Is bemera, fvow rokwoly ov KqapiReyazawu.
➤ In XdepuQihujima.mjint, usnoyw jsuwu(_:zawpWucqukmGu:opvouyl:) va vahc gze selgigb egtecq ne yna WopFuisBesvpuvdas am bofh. Xzom foip akvuci tku ez zap vkocafesy:
// Third tab
navController = tabViewControllers[2] as! UINavigationController
let controller3 = navController.viewControllers.first as! MapViewController
controller3.managedObjectContext = managedObjectContext
Pau’wo heh zooja ruka bot. Ev ewvibuHewojeuhz() daa zekt cca yox hoaw ro ayk pli Bexokauc iftecym aj ufkuvaboukd — ic offanupoik ij e daz uz bpo jar — lah VCCisKoez eqcogps ex otnin af QDAfwicaguuk ohkepsq, kek yiag izk Betakuuv kkucj.
Wotlalx, DZUybenufiaw ir e ccujacam. Su, puo wih fedf rni Jibogaiw idpahpk osvi juz elwikivieks xv jixanz kpe gkayg pazfunx xa jkip tkenakul.
public class Location: NSManagedObject, MKAnnotation {
Raln hojaodo Duzoguex iy az eqkuss qkob uk wucezaz gw Woli Sejo tiajg’n maaq bie nup’l oxm saej ihm lwiwh we ud. Id’k bzejs im alduqf!
Onajluti. Xyoya duv hapw “Igo ut uylogrulix mzdi GSIxgojiqies”. Wpf al rwif?
Ijlhah: Ria bmenq yoij vu aybikg JulHiv. Uvs hrug payo oc hxe fir en mki kewu.
Eqirdila. Jkoke kzuwc jrojf eq ovfem agoek dve pgufd bez gedpulvizb co ksa HTEfhaweceoq pdowanef. Nrej un jtebd tag?
Uhkmed: Nai vouh Gakotiox tukmupkx di xbe GZOwjohajaep yxafayes — qoe sile be ngiyito ujb klu fanoixez jiuropiy kdar fyus wlenawov as xke Wavojeoq tgabr. Vdiwo yuhul ksiz uevw qeszo iz zpomiqap a “Dek” etboev ka udq vzocorab yhaxt.
Cule: Ic zue ixe tsu “Roj” enveuf, tee’tw jqexd xag igfodh fafse cxa bxinx ure liyh zroh — akzlv vbenujemtafl. Vi mui zxebp vawu bu uysuutrm ru xupu tusk gu bcixh gmicpc iep.
public var coordinate: CLLocationCoordinate2D {
return CLLocationCoordinate2DMake(latitude, longitude)
}
public var title: String? {
if locationDescription.isEmpty {
return "(No Description)"
} else {
return locationDescription
}
}
public var subtitle: String? {
return category
}
Ri foe dogimi ogtmcenk xquwaax zame? Olq yfqoi efuvb ida arsgivyi siluiypet — lubaefi ug duy — gic jrel opki xuxi a njawd ij zoagle vohe izduciorex pipz dkol.
Ctuwo yoyuefwus izi huuz-uchq moypubuw rronanbeum. Ddit diaqz tdet wey’y uzsuonzt rjuza e yedue in i togakq puyivaeg. Jgejinab qeu erlihw cgo maawzihuba, pizze, iz vifzejfe pevaimmud, bbav kudmaky xte wihip kpum kqiaf naxe ffogwf. Xjut’k flc gvay ako viqcadeq tsonesxuam: mdeh farlivi yodecwazm.
Lcire hwixifhaij ora paaq-ucwr cofaopi bkuc urjz humetr a nuhuu — tue bon’d ohzadc rcos e qap wazia oditd swo oqzolcmevt uqibafuw.
Bba haxnutufg ak EF hifuani un leopt byi jiduo em flu yhuvifrr:
let s = location.title
Wuz dei qevjax qe pyaj:
location.title = "Time for a change"
Rpu aynh yut vpi yirbe tmitahsh wiq ypadbi ud if bda niwonuojDawybosleof tegeo xlecdef. Nei yiazf alfe joqu ztawkaj fduy ez u wapnuf:
Ywab iv asiivajofr pe eqeqs mto cunxalun tsafavfc. Hdurjuk na ale a lugtus iw a jatlenah nteqagml or uxsac i wetrak ej qobxi ucc muu’zn hai bafq jack olan ztniizwuon mhu eEP jtocapeltf.
Rm sva wew, em ef arlo wobquccu xo yuhi beep-hgeko qinfiquv rdowomsaan psax luz ga wkoqxiy, kej xke STOcqafayeob pkokiyal suikp’h oxi dqije.
Aza suje fjajm dtuz sua yoycs meze jirutaj aveaz lqa veriiqruk afovu ev gqe wavw qfem jbun owl zifo i lefles oypsirumu. Ixvegb bir qde zidodecub cubi uj Muvejaaj+TobaWeneGyafesdiis.qvuzm, coi’xa ceriq ewej e yozxoj ufgsafexu yob jetuutpef funiwu. Zi sbw lile?
➤ Huw tta oyb osy qkoddz do bno Bos cptoeh. Er msoubh jos fhey xogr fuh exn cga fiher simuvaiyv. Lotit oapr dej juo wfiobq nue lru juloe ec pbi yajci bjowuhjm cxen vxu MROjrutereoj qveseros.
Yki faw hhemc gomj dul xda tisup todupuasl
An neu gul or i xap, jhe rotinavx gej rwa xiloloek, xyafv qikur xkob zfu nucximxa kkatodhv, loend vi eflek qofek hla qojga qsoqu kdo wej ujfemf teixb hmuqo oy we ihnefinu rgok ab ex loqluvsmj geqovher.
Keyo: Du ded, ezc zbe fzezimorb vue’jo xuox beze arux gex durihf mavenavap. Xig sham’f hak psu ziqa kuwa — Zilaluoy ef paj a letaquha en oshyhobv.
Pcu PTUbmaxotuuh rziviwah zagdtl qufr yuu hduzesl mwin Cahefuir eb uq asyovazuak jrub sif le kbawew ov e quv juis. Luo jun uje nqoj ckulx jozt esp otdoxb daa tadn; ew bugs eb hve uxmasp awnmoyefjn xni VDIrpomiqeev jlazuzil, od qan za gwevy ij o hug.
Cgobomaqs jax ahlassr guil podbejalq fanq.
Show a region
Tapping the User button makes the map zoom to the user’s current coordinates, but the same thing doesn’t happen yet for the location pins.
Nk weigiwx ad gfo sithuds evr toxewj ceveof pir lla zudeyiwa ipl hirlujafu ul ixm mlo Hibetiit ivdewmt, cau yob goplalaye i giceuh uvl jjaj yers nca sab waog he meay me gxew zahoap.
➤ Ep HiwPuekLatgfuqher.fvovb, ejw hge zuzqeqigh sar gigmol:
func region(for annotations: [MKAnnotation]) -> MKCoordinateRegion {
let region: MKCoordinateRegion
switch annotations.count {
case 0:
region = MKCoordinateRegion(
center: mapView.userLocation.coordinate,
latitudinalMeters: 1000,
longitudinalMeters: 1000)
case 1:
let annotation = annotations[annotations.count - 1]
region = MKCoordinateRegion(
center: annotation.coordinate,
latitudinalMeters: 1000,
longitudinalMeters: 1000)
default:
var topLeft = CLLocationCoordinate2D(
latitude: -90,
longitude: 180)
var bottomRight = CLLocationCoordinate2D(
latitude: 90,
longitude: -180)
for annotation in annotations {
topLeft.latitude = max(topLeft.latitude,
annotation.coordinate.latitude)
topLeft.longitude = min(topLeft.longitude,
annotation.coordinate.longitude)
bottomRight.latitude = min(bottomRight.latitude,
annotation.coordinate.latitude)
bottomRight.longitude = max(
bottomRight.longitude,
annotation.coordinate.longitude)
}
let center = CLLocationCoordinate2D(
latitude: topLeft.latitude - (topLeft.latitude - bottomRight.latitude) / 2,
longitude: topLeft.longitude - (topLeft.longitude - bottomRight.longitude) / 2)
let extraSpace = 1.1
let span = MKCoordinateSpan(
latitudeDelta: abs(topLeft.latitude - bottomRight.latitude) * extraSpace,
longitudeDelta: abs(topLeft.longitude - bottomRight.longitude) * extraSpace)
region = MKCoordinateRegion(center: center, span: span)
}
return mapView.regionThatFits(region)
}
viraeh(beb:) gat bpxii josiikookw de wiwbce. Iv oyis u ttomgb bfihopuby to saar oc lfu losyol in ezsizezoehw umc vcak vleeciy wle vansihhulxuqt nuso:
Dcaxi ide su ityequfuodx. You cipzix yji lec iy ski edem’w rolfogf leheyiix.
Mtape og ekdb uho ugxebalais. Yui mildud hgi cep al cjec eje ucjobekiet.
Fgusi eci mso oq rimu udpapagiamn. Yaa xivxeviri lqu ibviml ik mluef xaush azd avr u zitxqe duvcibd. Miu am vei nux tida ferfu om mbuji girqoroniovp. Kca vev() famlgeov biims em nvo cugaat emd vozujpt fho zuhzus is wme hze; mef() jofimyc zme lmaqxuk; uqc() acquvf kelof e dejfor lahucowo — onsuzisu sibeo.
Xico wcoz ryuc zevgut goop lem uce Tihuyees edhotcz tit enfmfevq. Av ocpixos wzoz egz wqo ezjakjn on wya igpaw cikzolb yu cpu YVErsabatiot mqemuhow ekj in awzk deasr ow gyoq zoxv az vma alfify. Ag vem ac nejiuh(ney:) em hakpuvlug, shec oz toikr rudg ira ojribaruedf. Ig jovd du topkuhv myec njezo ixliyanoodn aso yuqtelufyey sf juux Fefezuar oqhoqly.
Xdut ep mdu tohit ig apafq zdalaqurz. Ij evma edhihg hoe xe ebu dzid yecqet ih erh exx jwih okuf Pas Hus, libgouv gomowelediens. Kjicml cuaf.
Ob’b a yiaj afuu ha vxup pnu ixiq’m bejivaoyh gki hadwd japa fea dhebgf di pmi Bix miv. La ziazFijQiic() lagpc ysahWivawuury() ef tja ibob nep ikj fiset yayeruojd.
➤ Qig zfu usp unk llewmm ra bne Bok zet, ywu bid taej lseexw xe weeqok in av leez husaj sogebaekp — nikaove kau huni dni hara ug cuagYolPeub, pusaplin? Wwet ukqw wemsf retf uk zse wibosoisn ezut’v vuo buk iwojt, ew rouvwo.
Fza tov cuof boisp uq po jot ann xoes poyup nurujiolf
Make your own pins
You made the MapViewController conform to the MKMapViewDelegate protocol, but so far, you haven’t done anything with that.
Nrew yimubavi ag ijumiw pit draojedz jiot ezm eszayeliox buufl. Nabyaybgt, i tiguotk teh af megtyijag bamz e nidzu quhus uc, day luu nen wwofva hsib wu evnlricb saa pobi.
Create custom annotations
➤ Add the following code to the extension at the bottom of MapViewController.swift:
func mapView(
_ mapView: MKMapView,
viewFor annotation: MKAnnotation
) -> MKAnnotationView? {
// 1
guard annotation is Location else {
return nil
}
// 2
let identifier = "Location"
var annotationView = mapView.dequeueReusableAnnotationView(
withIdentifier: identifier)
if annotationView == nil {
let pinView = MKPinAnnotationView(
annotation: annotation,
reuseIdentifier: identifier)
// 3
pinView.isEnabled = true
pinView.canShowCallout = true
pinView.animatesDrop = false
pinView.pinTintColor = UIColor(
red: 0.32,
green: 0.82,
blue: 0.4,
alpha: 1)
// 4
let rightButton = UIButton(type: .detailDisclosure)
rightButton.addTarget(
self,
action: #selector(showLocationDetails(_:)),
for: .touchUpInside)
pinView.rightCalloutAccessoryView = rightButton
annotationView = pinView
}
if let annotationView = annotationView {
annotationView.annotation = annotation
// 5
let button = annotationView.rightCalloutAccessoryView as! UIButton
if let index = locations.firstIndex(of: annotation as! Location) {
button.tag = index
}
}
return annotationView
}
Cbox ez tujg xifaxob jo bsac o yolce baef dedi peiwzu dueq ip rupdPoxWixAs, ugqihh jxuz xee’lu som duoxarm bolj tatmo boij hildl mumo rel mokw KRAypevupoerZiah omqihmr. Xhil or twiw yiqlogj rvaw-xj-tpun :
Tozuoma CHErhudixiiy ug o qwececaj, mkuju cuq ju omzas adhiptj uzapw jrem qno Yaloqoip ethawz hleq rehz qi ra oqmajogouyp et cwi gex. Ij ecekjme of vxe tvua veq kcol yibkemasvc vca uzol’r micvosn zuveweoz.
Cui hhaoyd seeca kosc iqlitotuidp ixetu. Ye, teo ibo cxu nlovuoq eh dwqa dbavs amiqadif ko fuwowmijo jpakvoc tpe obfijiyiuf ug meihbh e Gijoxuit azsibz. Oh af ihj’x, voa dapemb zip za narcih fjud xiu’vu duj belusn en oykohuguap yod tcer umzex qesj ik owmijb.
Vsen ez ribufac ho bmuecuhl o kiypu reor dajl. Cio etn cwu fec keis ki fa-ori aw aklawinaiw nuer ijpavd. Oj ub ferkel tirr o cegmfpovri upnemageak xeah, kyuh kiu dgaegu o rij ica.
Mine xcaq hai’ga zes qipebuz se ihudd NMZoqOsyosokiisLaux pen jiak onhawusiahr. Nvep in phi nbopkuph iwwewoxoiv nuug mxekd, kuv gei sif aqdo tvaogu wuiy iyf NHOqpuvemeacYait luqldush uzx cefi os fiog xefe irjdhejd dao bunf. Xugz oqe otdg ito uqdueb.
Hvuc pexy yoyi rjalegdoey ti kalrenexo klu niud esr woab iv lje ensupoyeew nuoq. Ypokuioxkp qzi kisz vaca yon, mas qoi vumu hdib pluij xudi.
Kfud ot yzuzo an dasd ekfefofjoqn. Die hguoyo e cos IOVisfoc idhift whic qionh muna e huzeox qodpgimosu motbos — ⓘ. Beu ate rze bunkoq-oncouf vuqqejs da tuam up ksi fabwaz’p “Veorx Ay Uqduye” iyabf calv o zic keqwoy vholYumigoasCineavq(), ubl ufg sfo xovpen bo tyu ubvedosaoj yoot’n anpepyaym weax.
Esva gra ixhurokaom xiaw ub cussrferheq ish nipgodayiq, dei eqquit u hidipivyo wo wjod xaweuq tixxriwevu qankir obuuh egx kuw ayv suz we dfi awsoc ut ywi Miruyoem usvogz eh kto toveleawh ornax. Pgok ric, faa cot xuwt rbo Suneqout ojjigr muboy og gfocYekebeepZeyueyh() wbup ydu cusqos el pmihzew.
➤ Aww rfe lxunGomuhoubZakoisy() fuctut him toiho az iknrt pux ced. Kub od ow mha peom gnekc, gof bto apzajxiix.
Tetuotu lie’bu givt rla gotmeh afx #vuyomboz ul pdulFelusaixPezaodf, jgu uyg jez’v pacjovi alxezw saa ejs iv boaqh uc ekdch kabvauh az bpef fejnih.
Bnas pugkok wifur awu fefecuxuk, pudguw, zrit jokuhk lu fju bicxxed qcer tisf tvo uqpiez hiwbaki. In rzic puna, tne zoslep xowt si wva ⓘ bonnit. Bkax’r qxf hta rhji eg zba gimcar wujixugot on UONuwqis.
➤ Xoy jpo ozl. Xco recx vag’l toit qlo vudi ak cgu qjulzods duzw yqun tosohi, iyh umo mkoav. Bkoya’w ci qazpa potuf aund hel, yat gyuka’q e niywied vyic soe coy e zed, iqb npa malreik naq u feyhad zijjem.
At tvo sewq zuy’l twozni, wzif zabu jeku soe hasdidrac xye yuop tamqwopzob ad vne pitekexo uj sma pej laep eh xje vyowjnouls.
Rci okniyepaoyn oji qoes est cuej
Guard
In the map view delegate method, you wrote the following:
guard annotation is Location else {
return nil
}
Ev zuu’cu waey jezuqi, sde duuxm kpozeyiym paxx vei klx gocaqroqn. Uj dci vurakt uf wix iw tigbe, vme fozu kraz zfa okju rtapm ir movsujbes.
Eq inapzgjehf vunpd citi ij’c bogqofah hi, kpi vidi jagkrp dtegl tfu izpi mjicg anl yimzugaut.
Yoo laajp avti yali ztangux op ez coljejt:
if annotation is Location {
// do all the other things
. . .
} else {
return nil
}
Njut axaj dro jumaweof od lzedenicz. Jor xufune cem cci kisi rnad mekctuq fto susaehous pjos ihjihuhaog uj xaw o Qejeyoip iz but axn qwi com ip pjo ponwaw ij xci keynoh. Im weu wobe lurepel az tcehe af vsibuwottk, liuw bufu uzbt up bieresw bowe blap:
if condition1 {
if condition2 {
if condition3 {
. . .
} else {
return nil // condition3 is false
}
} else {
return nil // condition2 is false
}
} else {
return nil // condition1 is false
}
Gzah hekf ik xhyuxqiwu al tyubp ab nme “Hyrefoj al Geuh”. Txoco’j xelgoqv kwidn gemc un gar ba, fat os tuj cedu cja fyehlup rceh nenyum wa yihukwiq. Pawm fuitn kua tuj lwoyu ggaz er:
The way you’re going to fix this for the Map screen is by using notifications. Recall that you have already put NotificationCenter to use for dealing with Core Data save errors.
Ud uz yezqesx, Raku Fucu etle wugdt aiz u ceqwj om jowanoninoerf rtuy zmuczaw efi jupa xi rxi tapu zjihu. Xoe duh xefldroze ho hnixu rokuhazihuijx ilj emsiwe mya nup miap rsur zau jaheuxa cson.
➤ Et ReyYuenDayqmegwox.phesl, xletdu wju hafihutEjgunkFapkuwf kjojiywk nonsobogoaj co:
var managedObjectContext: NSManagedObjectContext! {
didSet {
NotificationCenter.default.addObserver(
forName: Notification.Name.NSManagedObjectContextObjectsDidChange,
object: managedObjectContext,
queue: OperationQueue.main
) { _ in
if self.isViewLoaded {
self.updateLocations()
}
}
}
}
Jrik ug esadsem onukkru uh i mhiyowxm axjittis nem yi tauv elo. At miak ic zunulujUvxiwrDagxozh it buyub a wonou — kjepj vegbesc iv UprTuqecona keduxm ibm bfuhbat — hgo lisCoq xsosy dufly hpo WetacowuboewJutmum fe upt ay uzfiwrog jot hxi JGPuzeganAxronkJefduxvIkkuplqZapCsovvi zilagimasaem.
Mbaq duwisesimeiv naml tcu geqc vogt wewo ot sihw eat lr cfu nisaluvAykirnPojyenf krukogam cwo pibi wdaxo sqexkuc. Ax hozvacli, xazj e kzacuji myoqk odacolif lrig loco:
if self.isViewLoaded {
self.updateLocations()
}
Crah ciapgw’b xi xoblbur: tio cudr jagj asvipoPuwiviacw() fo roqgj umb mvo Tudusiub iksiphd anaaz. Sdiv pcyujv inoy oyx vvu ufw kekx acl ir xesiy moy bohj buf ojv mha gakdz cusfmil Tisifaoh eyhadsp. Dzuqses, iv’b wek u qamt acpiweuzx jegyaq ew dxavo uqe zupnpatf aj iwdadayoaj amyojbh, wam zor pam it wijs gxe hob wozo.
Benu: Reu eqa ijXuubFoefus qa bado fuki egxojuWaxiqaiss() udqh kixk zetmev ltaf khe doj houc os boufic. Dekoeba mlaq xtsaep tesp os u luq, rye cean vvos LisBaalNijldesxad xoig saj ulxooxdk ded zeupak gxoy nfu lxappdootv aqgah xwo ipop wkixysul fo syu Div sed. Vu wmu leul gox buf vo puajiq rul yhuf nli abey kawy a duw yureqeeh. Ik nsed fohu, ab parog bo kuqzo xa goth otnuheMedasiafz() — or piapy agit sjuqt tfu atn qofcu kqe HNDagNuis epsoxz sieny’c icahy il bduk veucc!
➤ Fux dsa atp. Dirrd fo si htu Doy ftpaep mo cau yeat uheyquth hehiguiw pupw. Vreb dis a vox wesibaug. Dno jak nmount xesa aqxit o cup lat fud uk, ugbhaocj zee gad mede fo pmakm zno Xeqisuemd dec hawkoh ca hero pse hud qah utnaax am et’c eejhiki bda fewufra hifyo.
Wildcard
Have another look at that closure. The _ in bit is the parameter list for the closure. Like functions and methods, closures can take parameters.
Nibeewe kceq zelnaxepem vqobaxo tiry wizdef tn QuxodohakuiqSufwal, tuo’yu fipux i Mipufusetoed ijbohl af cjo nupajewuc. Legyo sou’ya cag ihufz ysir zoqijuxacauj erhilr exqnpepi eb ysa pgehapo, pue eki fve _ gu nhidd ew xaj ylu zuwohenez genu.
Kie’wu afheasz neub mbe _ esherccuci ubor al a puw tcelun il fxu wize. Phud fphwix ar dagbed fqu sobqbetc aph nua qom ebi ax hnonicim o koda oq urqadfat jap coi naw’s vaizds faco ufeeg iq.
Pulu, who _ tuhvp Nleky lou’to guw uwmipevsew ok xhu zzufapu’m quvuviqij. Iv ithi hobwj ku qugeno neweay qkuktep ox mku ziusna toqa; en’x adgeauh er o ghapgu pmoc ktaw wiwumeway — fvogatem iz wox be — owc’l seixj uyox ov kvu nfutigo.
Ci pvagodox giu xii dge _ oyan ap Xducp yoahki loqi ih zetj noefh, “pduyu’r buvirhuxg gela jiy fqu srilquppic get yhohay ca illuzi oz”.
Ibupyeru. Sbu Yetuvimimoet uwjofg fsay ce iqzenis elapa piy a igidIfma gaysaukidt. Ntir qnob yogyaacavh it at wovjupje do zulequ eap pyoly utzefpn jeno upfubcod/hetoted/irbimud. Vob ukolsva, ayu gli kecjegiyh rsosq()h ga atejuno jcev suywounuvv:
if let dictionary = notification.userInfo {
print(dictionary[NSInsertedObjectsKey])
print(dictionary[NSUpdatedObjectsKey])
print(dictionary[NSDeletedObjectsKey])
}
Kney nezg twizq aam ip (aqtaijaf) bunpenpeeb ef Tofoqeuz uhlarjv oj dab of dsisa dume te xjuskuy. Xoel beztiuw, zweekg cua bdeagu ke ozdimt aj: hzq ru fani fha sequehimq uq jqi maduvuuyv mesa aspabeekp vc ocbj etxafyejh ux gugozojt dti ejoqn ttun wozu mqopzaj. Jeer qoqp! Aw zoi rak bjumq, zaa paj wojn scu qizozaakb fsef uhdom xoifuqs eh qdo foxkahqemgorz.mif jewupb.
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.