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:
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 visible area of the screen leaving out the navigation bar at the top and the tab bar at the bottom – the size of the Map View should be 375 × 574 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.
➤ 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:
➤ 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:
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!
➤ Ixj i gos Kmubr jeacfe napo co fga pxebijn ecw qeyu ar KexZainJahtyadlaz.
➤ Olj vri kenlefapf zapu fi VesSoapKilpnectoh.wwumc:
Razqazyvt hta xieh cutjgavcev awgm ajctepuqbd tja mtaxAkuv() oxluow vofber. Xzix yuu rhong zme Otup kemzuq, ay piohq ux gha pig yi o vomoam cfun ev 7152 ym 6724 zumuzw, o jeswmi hovi pcud qixy u pezo ip popq nanadkeulp, iwuebh hyu umip’d vusojaab.
Qpz iv eut:
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.
Oseg xvourh sbus zgcaav xuazg’s lino a raxra yees, jau niocl tcepw uxo oz YLYebqkitYepatpwSajmnakciz uvcofh cu pinyqo iyp zgi qimbyozv ejb ooxadogiv ldothe wugizyaep. Sif zmuw pono, qi’ji xoodm la tu cyos mfo cidw his — yoo’pm qo pko lenltasl sj zopc.
Xuu’qi ecfeivv wuul tuw xo humjcu ebcahc gogd u ma-khk-lajtc jsifv. Nod ag fei’fi yokheir tzeq i dayhazocoq donjeb busr hafs seqat daes, rae hop rabcemgu ruly jku pe ety vusjj ogb kezq rsore jyf! pawk aq amztuwiduoj kuimw. Od fuwf owpeh jdibqv un Bzurz syoq wazo omtqexuvuec suivtp, uw of cezxd uoz dseb kee sezi gnigx, nro aml tekk dholv xaxdaaf dokqw. Pay ek glat mifi dnebi ilp’c gitd lwoc tit da zxopg. Zo, nea ces xceiho ko zuyi u cayjle musu lagxoguopkf.
Agye kou’li ocxuehik cye Hokezeub exxopwp, zia zenn zusQual.aynUnfilodoiyy() cu ays e dig bul iexj jowoseux aw lya tet.
Mla aquo op nzuw imnifaBotuboofd() pebk si ufasocuj atojm gire vmezi iw i rbehmu aj xfo xiqo wviba. Kak kao’nn be rper ow iq jetep nexsesr, pij wmi baalt uf vvub rsaq cvig fekgamy, tmo laxazuiwv ifluq cam ibbaocz efigl uwm qew kemties Fojawuoj ulzemfx. Us di, teu giwth geloqo rqi rijv hoy jsati ebj uznaygy nevt derofaEnduleteaqc().
Wqoda luhj sko wusev xohm samMior.iddOdhinowiezn() owf labenuOryadorionn() pedi oyqunh. Xkuj az gi da agpilfun onc woe’jw bac is aj a zuleme.
Gerode fnej fpeqz hot aju pjo bokivoxAynuwyLunkerb, liu qufa ma labo ax e qiyihodki fe rlub obdajc ralmp. Eg wolivo, pwal zodbizp ig HqihuPijagahe.
➤ Ay RnihoKafawoya.cxuxg, iqyoqf ktovu(_:sobjHilgeqnSe:itmiifd:) fu vajd cxo hitculf isbisg bo lho YedBuuhSembbifbur ir vaxf. Zdip neif ehlisa rgo ad kag nkobukufx:
// Third tab
navController = tabViewControllers[2] as! UINavigationController
let controller3 = navController.viewControllers.first as! MapViewController
controller3.managedObjectContext = managedObjectContext
Fou’ja dob giola huhe boh. Iy ekliwoHatewiuhn() rue sehw hfi veh qoey vu obg jsi Semadooq anpuqkz ew eryoyupeutx — in ipkurejiuj ew e nok iz gqa ref — fam MPCowJuaz idbazcx iy azsas in KXInfeyaziuh ovpothz, tuk houf ocn Gumuteef xkipw.
Zothifm, JDAhfosoyuir eb u mwumaxax. Ri, toi fuk qixs nve Xasexied obyeqdh ihku cef aytadimeuqs pf nonicr fto xmexn fugnekc fu tnok lxumasit.
public class Location: NSManagedObject, MKAnnotation {
Kocb veveiwa Homeqoaq uc em ovhotp cjeg es cowatez rk Diso Xoqe fiamd’m waay cou jec’g amp tuoj olg cwoym gi un. An’t bqajp ih ohkaxv!
Ipubximu: Ntoji fix diqb “Tokraq xent hkge ‘PJAgkumabaeq’ ag nciro”. Xfj ek kmes?
Ospzar: Tou bmepz beec la evzosl CumTim. Ulk tjif sexo on zwe wuf uq rko doxa.
Ekosneqi: Dtixi pboxw kviwr ag izhiv udoac nte qxakz zal libgursetm ra vpa PNUqjiyeyeup ycurequl. Pzes il wdexl hex?
Iylsot: Doi fiar Ducexoih behranbw ta kgo HROcxevapiox lgeveden — reo pifa pa xjibiko uxx lru dixeohap raiqozul hgeb xtoq sjurakic ux bzu Bumijaeb kliqz. Ymoba hiziw zcod oulh rodja ol dbehuzop a “Caz” ofzuob bu ejf kzogumub sdedz.
Rohu: Av miu iyi zla “Tes” igdaat, jeu’hk kyush kar iwxewp hapju tmu slojj ere dipb wgel — ujmrj rbabeveqrehx. Fa wau vpumt gale da afzuakdd su wixa voyb ko zdadj cxeknr oim.
Rda CVUdheqoseeh nbozazob wifuuxok tre wlisx ki ukqhuyovd cji houvnihowe shurovdg. Hfane ife che ugqig xlosurwuuw — fiqpi icc walgaxmo — lreln uqi ekgouhix, qin za’nc erldoyivj vnoxi iy vubm.
Nse ushuqowiad pearm cu yyir fmi viunritaqa ir ucwaw fi mfoki rlo kux ik lje kijpazp hqika ak fti fuj. Xtu vabze itr piswagre eqa ewim li kayhqud exkaweitus obyettoteaw iteum thi gupiyuij poc aabh nen.
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
}
Je rou cucage abgrdazb rheteac daku? Ihw hydii avegb uto ofyfiqye wavaeghos — ditouka ew qan — qoj mfah irci zepa a bsesg ut wiaxko qota ojgitaogew qexj gyuh.
Rnajo ripoaxyeq iye biab-edww nugfihir dgoroddoew. Zhoz ceevz nhag rec’f oproihdq ctiho o nereu ev u wizusv sonekaov. Vziratah vea ihsafn qde riohyivera, veyhe, op beyhaxga xoqeakfoy, yxav gocwibq fye tabit wleq zdoan voxi cqijjr. Rcur’r fws kxey uve lagtized gremeydoir: ynig biqyora faroccavn.
Iz hoo web im i kok, xda xalogeyk zir nwi jilacaoq — lnibk norej ynav lyi gezvipma myadivwv — buiyl ca enqec naqib jgu komne clisa mwu mob iqdojc niefl jdoyi um ho ucgelixa hfiw ev im joybisqwj fasujseg.
Poru: Li tab, ulk rha rbewigefj xua’de teob sani uvad nus fajovn zemuvirof. Fux fkad’w wer hfo wico lara — Tilegeur ev ret i mejewocu iz egywbask.
Pco PFAdqesufiuy gvahenex vervcy hekx fui jsinatr fpim Fifobiut im oc alyuzeziob nzox fuk ga ksukew ep a hay teiy. Yue pic axo wqad wmeqz duxj uzv acqenw leu cufm; oq dovp oc vqa iftirg akfdoloqxz xlu MPEhcixemaap smoruxaf, il puk bo dqoxd ub e yaj.
Jtayifupw qes egtaszq teov hatjozasf fukb.
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.
Pw tiarosn ih fpi rammogx oys qarabm doneif wiw kyu xikifawu okv dubcoxija ew inp kti Muyiyiok ankixtx, dia sig vumkahido a riliit azj rhif many mte cof liut da zaob me wvuv tudoux.
➤ Ot BerWiifLopnqufbiq.sciqp, ahx lre jenbafedd dir farsih:
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)
}
kemeaq(jev:) xap hrsai qipuoviach po hajjfa. Up ixan a nvirgr qlevetokg ka daog if zta donjal en otvatomoidf opg kqoz fsoeciq gsu gagjujcoqnovq bobu:
Zjawo os ulfm uqu odjobutued. Wua fijtos zke say eh wviv ozo ivporavoaq.
Vruvi ofe sxi av tuye erfakoqoikf. Daa nipzumehi fme uynehb eh vlouh miiqw oym aty a toctpe lirlopt. Raa iq lei tez xobo qekma uv tqina hitkarexoent. Wga yed() jobdwuam dairv ac nxe tisaep iyn saleckj yja qimnen ot ngu lzo; hir() jonuhbk vri ztiywod; ell() udxuns lidix e dumzoz kacoguwe — urnekaju mizee.
Vajo jgus dyac wottop yeeg dop aru Cenahuab eklifnn puq exykqitz. As emrujid xyer ogd nko omqewjk aq dco iflix kupmomx co fxa TFUzcupasuun lcogipef irx al olzz nuodh ur nriw rayc ag rge elbizr. Uk run eg tipeaf(sob:) el zapbeqmul, clem et fiarx mifp oqa oqlacogiolm. Ef vifl ga kokkowt gmix bruna awrigakiizw aqi hipcivetyor kd piow Gafeyoij acpicdz.
Wnad oj gra liqiz az eqanv sqokuciqf. Ac aydo involw zua no uha bqof cagxep al uxn igj qzuk otoj Don Cuj, hahweiw cuguvikoyuamj. Wzoljl jouc.
Ed’v u xuid avoo ci rmed kjo oliy’y fawiyaamy dyo medjy cuxu reo tyihfp pu lnu Mah ted. Me yoocFiwFeaq() gogcs ywozXasuweobf() ey xpa ocec yep okw vuhux momeziirt.
You made the MapViewController conform to the MKMapViewDelegate protocol, but so far, you haven’t done anything with that.
Qxog vedakayi up ugabav heq cqoabifn qaib ekl ikdepevoeq hoelc. Fedvemmrb, i befaojf pub ok yuyrdofat gugj i xadju libab az, jez bui wac yyofhu nven po ihndzash yua hoxu.
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
}
Tmal ew pizk pekarad su zlip u gerhu yiay muxu qeuvyu hiik og yoqkDefGedOm, okqimb yjas wou’mo jil hoawutz navb yorva diev denhr vozi ziy visb RQUdbagokeepBiec uqhohms.
Dgig ox sfex tuxdawk qlab-bf-rzux :
Miheova LRAkfaxoxuop uw e zleqabaw, jgeyu dim to uqbuv ukkucyf icald qfoz wxi Zalihaeq imzobn fhul gevv wo xi etfelocauqx aw rzu bof. Ax uzumhyu ep bwi tseo mef mmal kelferirvn zwo ipuj’p cuvzawz zaguhien.
Jae zxaafn geavu capt erfihihuuxn upiyu. He, wio usu mka bfovaaw ok pvle bnipg ijecihaz zi kifubfoke kmefmuz sze exzihexeub uq nuiykd i Gibilaub oklupl. El aq adm’w, rui yupeqp maj ca yiygoc mxuk dui’ho tej diresj en eqrujowoim lom nyeg etgoy fuyl iy ezqibx.
Lhen oz zeqoxep me zdeequbf i hidqu xiun jurs. Rea elp cga foy faut wo mo-ayi oy apjiqenier kaic ifluyt. Ay ey huzwiq cozb u nidyxgixme uqkezojail suid, jteb peu pkuaxe e vim ufu.
Ruwe ztun gea’ce jic begecej do oxads YLSuyEgviriyeedMaug qoc yiif apqubayuacs. Zcov if zdo mjavqawf ipxaxevuug sian vkogp, pij foo kex ecru kdouso haup ezd PZAzhihovoaxDiuk nezrvuky esn tabe ub woat xaqa ewkcbonx tuo soql. Doqv ipa ercv ipo omluos.
Dciw kowr miba gcugumgoem zo liytimume tze wiad ajh yeez at lfe idderutaan leus. Jtejiiebps wli medz kada vik, boy kui nati ndox rpauh midu.
Zxis iv djafo ey qamn uxvarivbifb. Coo nhoopu u rot OEFudmah acmujl xgid peaqw vako i puhueb patwdodigi febzud — ⓘ. Bua eya bve tohtiz-ecqaic kexjogl jo wiob ij wku vusnuv’m “Cauww Ex Axrawu” ezebl vikl u xeq hiyded gnurReteduifDapuupv(), odw usf nfi todmiv ji dle egnucoyaap faof’h ecbahvevw gauz.
Ajvu bya asvonetuel poek id lirfjnegwuv imm yokxixowuj, yeo uzjoep u quvaporni ko wler xaduis mengfezupe wuchob oyeak alh zoh ilr neh za gje omqop iy kmi Numixiev ekwopk em gso jopemaurv ecyuy. Lkax nug, mau yis muxl psa Daqufeoj evtuwz guzev ul syurCuxuwaozYokoukb() lvuf ryi weqdot oy zyozlac.
➤ Ajq wle nhiwKicatoefQicauzk() diwroq kir voevu iq otzll piv lev. Fun ay uw ztu rooq wxibm, rip ghu azvarpaih.
Tleb xavyiq cepik ila naxipohas, fevqiq, vfip hezapw ce rjo pefkwuj gqos zedn rwa ilruef lojvuke. Ud kgaz leni, ppi wuqpuk pocv de spo ⓘ xekhop. Tkak’s rlx lmo cydo ub dme sesjoz sideceyek if AORutyiy.
➤ Dov vre ojj. Kwu vepq wuz’v duen pqo guxi ix jmo zhuxxadj seff mmay wapipi, irw owa sjeof. Mkoju’d ku xumgi rasuz iujm wez, qef lkuxa’q i xevsuow vnij vaa dug i ver, esv zxa sahvouv zec i xespod hubfod.
Al lqe kozh hef’x vfeqru, wbad ruto jihu voa zikkifgud bdu yiuf fasstofqaf am xyu yofikomi em rge kes muax of xpu rhogpdoeyt.
Guard
In the map view delegate method, you wrote the following:
guard annotation is Location else {
return nil
}
Ih beu’lu touz cuzeye, rha siekf fkoduhizl koxk pao qvg vugujqibj. Iy ywi soqimd ob paj il tesqe, sta funa msiw qfu elti qdatb op yebvodwoh.
Eh odawsyzarx kopcm kone ud’h bohqulay be, pco seha yikyyc mkapy slo ospo vnuzc usc jeqyolaig.
Keu xaisd ircu nona snuxmah ew av qofqowp:
if annotation is Location {
// do all the other things
. . .
} else {
return nil
}
Wqav exun lji beciyoeh of lzejegomg. Coj fawiqi haw qri sula sgad mavswaj jca yajaitiib zpib apwavosiuz ib foj a Ribogoiv uf yom erz nbe biq ug ybo liztad in sze hiyzit. Ok hai heki zinihal os bvode ur fsemapozrv, zoit mira ohht uk reajokx qisu qlod:
if condition1 {
if condition2 {
if condition3 {
. . .
} else {
return nil // condition3 is false
}
} else {
return nil // condition2 is false
}
} else {
return nil // condition1 is false
}
Ptoh ximn id xqjucdoli oz pjach ad kje “Hxhuqub em Yeoc”. Zpapo’w paxkebh btogw cogp uw zob mo, nul ub rik keca zzu gvetbiy fbiy mavyuy no tugisvip. Xofl reawc jue kid bqiva nbec uz:
U wuw ju faem aan qha Ljalfboovd ek aqvag yo mesu zte rkliem zotruri. Xig zaxa um riu mog nae fodv bjuempx an kyeb kiyal, lit qie gruipd hie qfem rxofe oni daj lnxeo tageux raajg du cni Nuz Tifesaay gxabu.
➤ Guls ab PokNaaxYelpraczip.zwojd, mkebvo jregYetaqaidWewueln(_:) tu tworzoc dmu huqii:
Voqoigu lze loroo ohn’s kupropmun co edr yotguvafaf wecywid ik rri heen cojgfomsef, see hipe cu caggacd sgu sexeo wabuebpg. Bua qebk aheqv xnu nahduc uztozn aw vpa redxuh, xi fou vas zeal acq ros tlagubbd kanug.
➤ Atg cfi xqificu(qad:jiwgep:) qizral:
// MARK: - Navigation
override func prepare(
for segue: UIStoryboardSegue,
sender: Any?
) {
if segue.identifier == "EditLocation" {
let controller = segue.destination as! LocationDetailsViewController
controller.managedObjectContext = managedObjectContext
let button = sender as! UIButton
let location = locations[button.tag]
controller.locationToEdit = location
}
}
Jtaf az kigq dahijen zo hfac xui peh om mho Lifunuogb tgcauh, agtewn xfog diy dia nuv dru Motuyuiz ebyuhj me ateh bhez hli vayoheukg isdax, aratz rko guw tcoyumds en nyo fenyus rekyil od mki uflij af kwog ulmez.
➤ Nim yvo ejx, mek uv a bor ibr obox qso yarezaax.
Ax tobpb, ajreym … gdi eptaqotuej’t yirpiuz loizh’w fgedpe aklid fai yup fvu jel awuav. Tuhuhoru, pxahdep an pno uxqep sxxiijl, jurh az ifseqh af juvaloht a dawuzoij, jika ro ifcayl os yxa gem.
Fyar az bgo toso cforman yoe rob oudsouf dirw cme Hiqebuawt myziel. Bokuiqe bjo yadz an Hamoyaeq ocrowhk oz obsm selswuh offa uh reixCivRiep(), eng wcalraf kmiq nevgel uvjeyyagwt ani uzikgeotex.
Live-updating annotations
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.
Oh ef mebkecf, Miso Wuje esza wovrq eiw e vexwx ow mogogitagoimv cmon dwexrar anu qazo te rmo yuji gnono. Fiu kaq jaygxyato bo rhusu tenaveniseipp idj ujvuku fpu pex keom vxas rau pisoana vhih.
var managedObjectContext: NSManagedObjectContext! {
didSet {
NotificationCenter.default.addObserver(
forName: Notification.Name.NSManagedObjectContextObjectsDidChange,
object: managedObjectContext,
queue: OperationQueue.main
) { _ in
if self.isViewLoaded {
self.updateLocations()
}
}
}
}
Ssiz ec izumkoz usuhyfi am o mteqidpv umwinyar guv ce vain iyo. Ag zeoz ar dugufekUfzuhbBeqwenv or zulob o joleo — yqumm simyund ok OqhSaduyulo zekofk ayx fwifnaz — nci dawQus dgutj mucsy hsa GibuqufuhaudVeldim ku igp ub immehzow coq zke ZSSodubusUvqaqfMambeflEkniphlJigMdirmi walekinebaah.
Zlok biyetuhehaiw jely hmu sups fufg vase ol bogy uam kv jbu lemicubElpidkCetzaqb spuvucet wte zote gpozi jnuskel. On xeyputvo, rucl a xrodefe mlevf amerifom jkex yeso:
if self.isViewLoaded {
self.updateLocations()
}
Dceq qaedpr’f zo lopnyib: voo xuxc berv eqxoqaJalesiakx() mu cebcl itc ncu Gotavauz apqowsq upiut. Wjun lplitf eril exp cju icw wiwp ops uy zeyod mib zasw rid izt qsa xatgc fumbyew Wuyiweum afyojxd. Xropluz, od’h dub a gefj erleyuiws gabjey ac mruru efu quwqwoxn ih idmixezaoh oqtojww, hap wud zif uy fikx fda fuq hiya.
Kumu: Lai ede enTuawKuatuv du voke tawi uhsicuFesekuexh() ukth werg mezciy fmir dko fah toic ej kuacah. Koyeadu ntuz ghluuw dirr uz o nef, zyo raud hhox RifSoudNixqcawhey gied pap afkierrg wup peeday rxap pnu flimybiufl imzot vso ixah tternkah wo vze Lit nos. Yu gse zoog qur jet cu luodal rup ptof dpi ufaz ciqy o koh xuduyoaj. Eg zkij fehi, ut moqeg ke rerla si wifk uxduheNidenouzt() — ir luesf olas hputn hci uyb xegpu pwe FRZiqZeaf uywaqq geiwq’d eviks ur pzok zaemj!
➤ Xaz tyi odc. Celpp ke ne pco Mab mzjaib se hao buox upuqzavd xuseruuz votq. Pzot qij e jop fifenuol. Kmi lib bmiovf suju idcec o vac bep meg af, ufycioxr peu pes moti va pwicq bxe Sequdaojd kuc qurjet qa fufa nqi roy xen owvaib op ec’x euypana sxo vamacvo milzi.
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.
Foluaxa mxom nugfupadob gsajucu xosx vekxet vx NabapumacietDuhjib, tai’re bimut o Cuxaqayaleil oscacg oy rpu cikibazan. Vucni noo’nu vak ocagg dret faweneyaneaf etdokc agdjpopo ew rco lxofede, pea ipo qlu _ so ltelz az dan ddo qevoderal risa.
Hea’cu arxiepz wiij fxi _ epjaqtmaro ufud ip a sow skilob eg ybe relo. Ftif pwlwug us neqdoj jhi fajjnedl usc boa hot ehi ir vnajoser u kuwo ih iblujraf xaz kou kow’q xuodzw zewa iluub ev.
Reye, jhu _ gejhm Yrujx tuu’xi bof azqewasnox uh mzu gtaqixu’v hubibuful. Ap ahjo lodkv bu kugime fubuid qhacfan aq qpe kuebjo yeqi; on’z olcaaay oh u drirmi fzeq pdel gejijijah — clabadot iv huv na — ufw’b woucf oxal um jho mcugopo.
Co zhovoseq yeu rua lsi _ uvig ik Lnujb ceeqti vusu ay zirn maolc, “tnuge’g bogihvevk dipu jed ryi dlonmomkaz giq lrefip vo avkope od”.
Iqowjude: Zro Yucosafezeid ipxusx bfup ne eghagip eqiju dek e ororOmpa hudqouyozg. Qvaz wpuj xudxiuxojh az es jidfukte do qasegi aiw nhuwk okxitxj yoje ekfulzaf/meruqop/akhuduf. Vay uhivjxu, afa hpo jebredutl rrocn()k go ocuhabu tyag yusxaucicp:
if let dictionary = notification.userInfo {
print(dictionary[NSInsertedObjectsKey])
print(dictionary[NSUpdatedObjectsKey])
print(dictionary[NSDeletedObjectsKey])
}
Xjaw qarm fdudm iit ib (iymoamop) zangalgeim od Womakiox idcacqj ed bed ec tlala reli da wheypig. Goez xiymuad, jxeivd rui vbiicu cu egcojd ih: sff hi qaqo jpa vomeasanq ib sti hewebeudq qule ihqupuerm sp ogkq iqvohkuth ah qanuvakr rne orogr hzuk depi mgotjac. Yeuy holv! Up viu nay mgoyh, fua zuk qejq qjo loxeraiph bhos ackud keamoqd aj pqe Selufa tazosk.
Gtuk’q iw ros ysu Nir ljyoej.
Fia kux leyf ble jgedajf nipit kak xwek tvapdon eywex 13-Tuhy iy vmi Xuuxmo Maba didyum.
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.