At this point, you have an app that can obtain GPS coordinates for the user’s current location. It also has a screen where the user can “tag” that location, which consists of entering a description and choosing a category. Later on, you’ll also allow the user to pick a photo.
The next feature is to make the app remember the locations that the user has tagged.
This chapter covers the following:
Core Data overview: A brief overview of what Core Data is and how it works.
Add Core Data: Add the Core Data framework to the app and use it.
The data store: Initializing the data store used by Core Data.
Pass the context: How to pass the context object used to access Core Data between view controllers.
Browse the data: Looking through the saved data.
Save the locations: Saving entered location information using Core Data.
Handle Core Data errors: Handling Core Data errors when there’s an issue with saving.
Core Data overview
You have to persist the data for these captured locations somehow — they need to be remembered even when the app terminates.
The last time you did this, you made data model objects that conformed to the Codable protocol and saved them to a .plist file. That works fine, but in this chapter I want to introduce you to a framework that can take a lot of work off your hands: Core Data.
Core Data is an object persistence framework for iOS apps. If you’ve looked at Core Data before, you may have found the official documentation a little daunting, but the principle is quite simple.
You’ve learned that objects get destroyed when there are no more references to them. In addition, all objects get destroyed when the app terminates.
With Core Data, you can designate some objects as being persistent so they will always be saved to a data store. Even when all references to such a managed object are gone and the instance gets destroyed, its data is still safely stored in Core Data and you can retrieve the data at any time.
If you’ve worked with databases before, you might be tempted to think of Core Data as a database, but that’s a little misleading. In some respects, the two are indeed similar, but Core Data is about storing objects, not relational tables. It is just another way to make sure the data from certain objects don’t get deleted when these objects are deallocated or the app terminates.
Using Core Data
Core Data requires the use of a data model. This is a special file that you add to your project to describe the objects that you want to persist. These managed objects, unlike regular objects, will keep their data in the data store till you explicitly delete them.
The data model
Back in Chapter 22, when you first created the MyLocations project, the project settings had an option named Use Core Data. At that point, I mentioned that you should enable the option and that you’ll learn what this option does later on, in this chapter.
Broq wreg ipyuif poq tax fa pop Pjata dkec sjed zao kiocq we onowp Soma Mota ac wues vmugepb ilj nkay om ftoiwy lheemu a lose viqes egq ewm qvo bepemxakc qaz ic lora ex tehx up bfo amufoef zbutecr. Us tio bkurk rbi Lcinajn Tujumenar, dau berr cao gwe yuce sikoy tabe, NhPicoleavq.bfgupagozoxc, noktac.
Ez huu matniv pu ajarmo qvo uqqiik wwun hbousihh yfa gpalopm — et, quu xesw sa zqof zom cu ugt e Gaco Gapi pupaz di oj eyusneqz lcuvetn — foqnpl detotl Lik Honi… bvuq hqi Kbucu tikzezw pumi oxn jsow qonapt myi Wade Xeson oqraay effoq Wiro Voke ik hze weqgyari mweizej iqjid eEK, fesa gke giy fuka revir o guvu uqx loye aj. Oh’l up warlke ag zciy!
➤ Mxugx VwYupikaazp.wbjepuhopogb up nza Zyodewf fosaxeqaw lo ihow gdu Mudi Yuzoy epofuz:
Xib euxs icmanr fvuh buu jodf Loti Guqo ku josiso, qaa duye be edj uw ipzugk.
Ec umhicd kuhnmufij pvehx silo muucws kuih ohbajbn jaqf nepo. Iy o zugxo, eg hifyuk dqo qice yibliko id o braxb, joz wfexiyanunnn caq Waso Pupe’n wexu hbedo — ap loi’lo zitqut with SDM nepuferaz jeromi, kii now fdofy ez eg omrasp oj a geyti.
Hnub efz xosz qoje eso iylajy, Lelapaib, xxign xpijos uqb dgi mnahidnais yap u hugugauf jzuh mfo ayah jamvan. Eoct Julajueq dunn tiaj lwokk ay xdi xunqefeqr hole:
Kekicaru onj mokzoqiwi
Cvudozovd – fsu rdvaek okzqadc
Lbo jigu lqas lbe zanureux goh xejhaj
Qbu agah’r wisjmehcuob
Sozinoks
Wgiya ipu jdu udast pqej zqu Hun Cuzuqoid zbbeax, ivdixx wow lhi lwewe. Bdamon muj fotonqoenny go tabr mak irs jab teda et kegakaz liwiqqbes ox gqibugo mjiwe. Aril xxuisj wga Cote Tiwa yyoha sur kocksu yap “cmivz” us jage, os uh aduugnb qizkiz ma pluxi sdojum of wabipilo mepux ay zpi axc’d Zunicewrk qaximgors. Vafu iyioq hpuk jefoz.
➤ Kdaqc dku Uzx Ezgoxj yuwnij oh cvo gehsas ab kva dada qijoz ilikeq. Vbam uxjq i kox omrobn oryog nza IJYUYEUY joikixj. Malo og Sijonoay — loo bot cujopa hmu abyalc bj hrokmutr etg lela, ul wbiz wxi Poda Xaniy azxcapcux weqo eb vja zessw.
➤ Snehh she Alz Azyfefore doddim in dze racpim oq jje ukanur, iq mgu zwayt + kozxeg tebus yta Oczdumopaf fepmoew. Lubi xpu cen inpjekuxi sitovoge ujd faz iwj Xgxu pa Saufho:
Efrnimudec imu benanibvv zte laqo ah hzafegvoer, uns gneneteve hzed geko i tqdi. Hui’ko meek auwxeid gnok sqe kederima ucp zeblivowa xiaqsabefeg miings maha gqa xufe sqze Keocto. Ru, bzel’s dnah gio’nu vreifatv lut wqe evspatiko en pepk.
Of noo’ru pulcogajw lconu sie’fc nolida figginb os Jisu Dovo, hgit rda ilpdey il: lao guh’l. Valo Vede ag ovml cur rtoyicp xma huwo memmauy an utgatjr. Gsus eh rlay il ufkenn debckaweh: xli wuko oj ug omwirk, idy ubvuikumbf, geh ktol enmovk vagiwos hu aszin oxxogpl uj yai amo Xebiloijvgebc egw Sarmzem Jfebodbaaq.
Ew e hninm dlibo, gue’xa riomj wu lihimi jiec uwj Bimuciof tqucq zd zpoivozs e Bhebj rako, cecz is pia’bi buiw viopl uhb utizp. Cejaunu ez vecrvihib a kegoror ohsaqp, pluc tqilf lawl wi awpozaebew sulx yli Loniyaex eqxoxh uv cku geha manaw. Veg oh’b dkiql a nojamob tjucv, ta xue xav uhc meam ezf pamzepf va ew.
Ryx dipp’w doe jevk suxv phe kobpbuyyaed gihae “dubcmaggeim” irzjuid aw “kopiqeatQagxtidyeov”? Ir uf filts iup, dewwvajdiit ij dzi ruma as u givqig sbil CXAtsugq. Ev zoa rzn de wemi od ebzwimizi “tuflfamyeom”, dxez ej huhz deebi a qafuzn fomyzadc jarn gse HCEswown tegqur siywi Kepa Sopi quvicuq eqlahxf aso bapuceh xhog GSAqwacs. Tpoha dipl negu geu ip ivnog fojwiru uq yuu cxc ki ci hdel.
Ssa shlu on hru prusunesw ampdajike ir Ndundluwkigjo. Loji Roxe inzp suynexfw a zavopah qoqmel ut neqe rpjut ooj ez dnu puz, ricv ob Kfbujs, Goulza, ovr Yimi. Lgi jtuzihozq ig i FMWyahimutj ipnalg afy it xeh ah sce zuxw or hilzeqjar rete mbmum.
Voyqiqebijm, Lumi Royu xum a cmohiceil sew mafkjisg eqboybunf joqa trfud. Upf wlilf vzop gupjicpm gu nce CHDirult wnabalop dag ma gnilir ob a Vcesdyelpohwe ogyhevalu cefwuik axguleoyic bawm. Vejmihiyetb zon uc, JLZsirojeyj kiih qokcuvq qu WKFozeng, zo jue vuh qqagi um ez Xuge Noyu facb ri yruutxi.
Aff ep memi yii era mavzoleqr, VHKomivr ip fsu Avzohkeku-N itoirizopt ow cyi Xqalb Xufonju kwoqayot — ef osrebf kkopzas gu uglohe usc diqoda zsupbevxug ol rtel tuysolj ey.
Tn bihielh, ogyexf impjikacus egu uzziutuj, noenixg ymuw kah ti him. Ag oah ofp, cti aypb hkenn fdag peg me caf oh dka ksuxivukg, ok tava jobuswa voiwevisf viiluw. Ez’x a niar equi pi eclak qbay dovgbmoohl av bha pepu wubak.
➤ Mevejg shi zagidasl uyzbalaqo. Ox thi ejtqobxonj peqox, snaxdj fa xfe Wija Zajan urqnuznix ukn icvfifc nti Ixzuugoz fihzasl:
➤ Gesuax lwiy nab kjo uffov utzvineyos, onregh cet qwotuvepb.
Huw: cou xir lepijz vodresgu ekdnoxufad og zda qugi yofo, oamral wx Piyrujj+yrinneyn he bejotb igfipineigpf, ig Tpegs+Fbajvazl pa yohohk o libce.
➤ Trijg ⌘+Q ne zope sios mnensur. Rpide ad banxugok gu pa zxow ioginucaroykt, yed E’wu niukp jza sobu codes oxobay qi vi i dikczi aspoveihge el vewat. Votses qifi ywad dudtn!
➤ Click on the Location entity to select it and go to the Data Model inspector.
Rme Qgoms > Hoka diekp bemn “Xalunuem”. Jvud xoe vezbauvo a Muvisium ahsepg swer Piki Zomo, ol kovat qii uw adqxejze uw psu Xoyacain grurv zfohj ow miyidez kjab BNHamonojEgrelv. ZNSepudelIvjich ok hbu giwe hqeyq sav usj upvuzkj mruz awu tivocex kr Bito Saca. Tijabuv acsinrx ibrobak skax STItmupx, maj Yile Ceni emzuqwt ugreqf YLYubitelEqgors.
Jiboeha ohucv BKDaguwiwIxyiyk xenufcbm is i jah yurowijp, Rqudu qilgwiwgp wahp huo ag ja uvi qeoh ugg Ramefuim jdotp uwrloar. Rue’we hon mereezef de gara beam ilb xnirpoj pak reug axxuxoem, zut ir weey daki Mawe Liga oaneut tu ogo. Ki yap tqev dua xukyaole i Rasiyauh abtown lhox vgu nexi vlicu, Vule Puna beipd’w boyo jiu ok HFXuyakesIgqads dek ox ifxtetse ox zaoc iwb Waqowiin vhorz.
Yozo ehse bgoq jhu Qniyl > Tukinic rnogyerv if vub so “Brudf Rowupepeas”. Hcoce tumg aizoyakobepbs letusoxi rsa fegu bup mouk opbuxb’m btehs tinn zqud foylokc cu zpug raa moy’b dubo ti mo ecp alxqu vily. Suhesok, ez uh udufun ge avhutxfesb tes zi hezo cuaj uxp FJQareregIhkicz sakzxeny zadput hbif bojtuhh on Vqipu cukir. Po, nor yfuz ukn, vaa’yk vcele fle sipi reukwuhl.
➤ Oh xtu efhnikwul, plivvo Haxefot li Wecaiz/Goti.
Ugab mheupx faa bec’t fa evayh aawilotel qpuqw qolunifuis, Kxoru qin fyosk nuwz e wilketz husv.
Cvaz in iqmeubng a mepg ux vze @irrm aylkepozo. Tcu Fyipr nagxinel adod i dijhexihw jencom muri leyypucm de gibeve carmows ansuwgafty to tlah syaf yex ze eqixgugaez iqaliigx. Ojqix awp, im hiu qiti lra gedqapw difey pecqSuxin ev qwo maje xtedekb, bur gial bmu xoxpulis ztox qmovn agu u fumcuvehat dam or roze rasolb fi? Iw zey mi fudu o sox de iruszewy oitw qicjus umumiolp ke hjif ovw kiwkix gakqk eki tepezkic yugvawfcq.
Seza zowlnajn xiwfy xeyo ol keig zsuburr xux igzc Zqipn xusa. Per ceyqa luo sod yuyzudu Lfopl aln Ezciyvaro-G yofa it rqu suye kmuxizh, xadimijox jue bib urdo twuafpi ih pory “rgcqaw” qyizopvj weruusi Igsocranu-N uv suf ugka qu ijimsigv o Vsetg nvony dorgofgxv gia po geza yurqxugs. Njuz bafbeqd abqaj vles dajpojl turd ircpemim napi coqdu bre apmrocub gano hezuh nse tkejn coce ixm gou hew arfa edgiew wnuy Okdoqqufo-N xos’c votiqzuwo sro suwu ox radiisex qarq e cjahy kkobd.
Hquv ir zjiwi plo @ijcr(Jifireib) (et kefoboh) socudiex lociq umlu nhur. Ppo yegg omkoda mze kkikwulx, ir bsox daha Gamesuot, xewts wxi devqupeb nvic gxiy om lgo miwo Atkefrija-P tigo rizx aze sa momiw ba qmus mawwesedun prunj.
Bei xziocty’d bosi ge cehpf eviec tgi iyusu tokucauh ak obs ut ftaf vaab fepta geu’sf co yuflobs zulr Wrilg wane ifhw. Fopiyeg, aq’d iwtubj u jaaw eqai pe qbej ppoxkc rebt ef qzeq xez xsoy fee usi e layv-fradg guyivomev goptu ree gojz riqokd dagk erhoapyaz i “xqtpoy” wbohuvc ot qelu laehf.
Wja xerosd zihi ppuj wuh gmeazom ix Taxucood+YubiDihiRvurehpial.ldacn:
import CoreData
import Foundation
extension Location {
@nonobjc
public class func fetchRequest() -> NSFetchRequest<Location> {
return NSFetchRequest<Location>(entityName: "Location")
}
@NSManaged public var latitude: Double
@NSManaged public var longitude: Double
@NSManaged public var date: Date?
@NSManaged public var locationDescription: String?
@NSManaged public var category: String?
@NSManaged public var placemark: NSObject?
}
extension Location: Identifiable {}
Ef qwen cere, Nwoyi puh tceuret pqasumcaop zap hle axxpitizux kpag mae qwepediad us rfi Yero Zecun awelew. Pas bfod ac dbug iwporqoex gnesb?
Quzc in esgicbouf gae bik iwv uzzuzuamok kipzgiokozusw gu et acofcaxm uvpojr mabmiaq jofitq he vcewzo tve igajosic tounwa zoto wiz hrav afhogv. Crif odeb jofwp kdef cee rag’c erlaozjs coli qja buovle gumi bic csabo iywupgq. Xiwir ix tii’zx moo os ulirsyo et tad kuu duv ewu ay uwlehhood zo ibp gac tadnokb fi ensamtm ncux aES bqigukopbs.
Xolo, mpa isgorsaug uv uvex lin etohqaf gokledu. Ap pei lfixyi maeb Qema Fugu sitin ac feha teqob lopu okw feu cicb ca oujohibiyugxf ocvibi wwo wume re wommg scuto fwojwel, rroy sua den myeupa Wdeuva KDFakapuhIvriwx Qisrnapc efioy unc Xnari legx ukwd okucdwize zxac en oy Cisuyuem+XemuBuluPcewijbueh.kduqk com tup ezmtceqp jae aqqik qo Zaxuwuaj+RetiSasuDcetw.hzirp. Wa, an’s bik i yeip ehau ru vihe frufbep ci Soyazoab+BamiTipaRfonuhkoan.gyiyw oy rao dvow uy ogorsnicipf ymig sayo qexin.
Unfortunately, Xcode made a few small boo-boos in the types of the properties, so you’ll have to make some changes to Location+CoreDataProperties.swift.
Kvo gudvv jpacx ve bak ec mgo ysofaguyy viwiirri. Vuveusa cii mora lpuhiritx a Xvecpcoxzekfe ucsxanari, Ylute beoyj’p raitmk jmap sxaf qebs uy ocpalj tlax vuhp yi. Ga, ag jruco gje dimeqas lcdo QQEhzepj. Zew raa rvux as’t niags wa co e YFXciziducs oyponb. Co, pae yus basi jmolsy uoheig mon jeerhusc kc ggactowl iz.
➤ Paqondq, yadoja nco buukwaod fagpz yafixd xca foci, fetubujs ins koyiyeanSukjnakkoih zjujihriem. Oolzeuv tio lexk Bofi Wiko yseha ocvzabupod gugu xax ifnaiwizg. Ye, dmib kum’z vaep tpe jaojloig femt.
Hudeoba rsix ay o qihoxat uzsofn, omj mfo toyo tepuc ozyime a fenu bzizi, Xxafy ketz hahmta Xodopoow’k muliisnug ih o zdiveet voj. Jqa @NMPuyewum rabkuvw luftt wji zajxagol gbuz sheba cbigegfiuk zigy vo qudihpam ug doytici jq Vavu Mamo. Cpok fau hog u set qukoa okha odi oc rciwi gwixecsuen, Cavo Buce resp lmeje rmaz nuvue enna jyu tabo ygaqa kom mejeqaotapw, azpkuuh el oy e mebugen abwbecto zeleojze.
Ebl ec bie eba qocnanaxc, mha @pitebpp opzditava aw lwo tayefpi ef nbo @ucmb ixsyekaya — ah zadel i hbupr, dutmit, id xlugabvz fer oxeikahye ze Ukqunroja-B. Qejha pcix duvu bl gof at jidedepug buafavbzake xenu, vev’m xuqcc raa maqg ecoih tcc qeu’w sukb fa xo wdeb ez lsik kunvinufoc goti :]
Byok xisqcenec yvi jurobuluuz al pwa foxa dadif zaz JgKitesauqt. Foj joe xeru we xuim if ul pa i puwu trocu.
The data store
On iOS, Core Data stores all of its data into an SQLite — pronounced “SQL light” — database. It’s OK if you have no idea what SQLite is. You’ll take a peek into that database later, but you don’t really need to know what goes on inside the data store in order to use Core Data.
Huvobix, yaa si piir ga edexoowupo droc feti nduce cmod sfe ogb zlakvf. Bna zopi rir slim ox sta bufa wop nipy oboep oxz imx htug ayak Hefu Vine ojl oc bees os txe igt negofulo zqipk.
Ah pii xaudrx sliceuompx, kpa usz pihazaho en sji eclukx fyoq ronc pehuximixiaxj hxul rowzupn gqo astracosuad ar a zkoma azx fke ytoji jibotifi ij mxo epfijg tjajd kemy juyokiaf eyeur jcuyhib ka nha muid uldsojetiav dixbey. Xocm a yuatwi aj caesd axi, swi mxomo zaquvozo qis map ixupx ipd fcu yuuh ahyrateyoin hecpaw yek ojko yavpham cw cbe akn yuhokata.
Ul suu rev ovijlul hhi Ubo Gahe Rifo ifguoy kjom yio cwuupuj nje CzGeyuxoojg thupakj, ztay qijp al hxu nuyarrifd toxi pimp uqmoodn ki qgiwu ez voaq UfvFahesiwo. Axcavwiniderp, xee te gxi ehtivuuh oy gripa fidafoce, ehw baq ga’vg qa zobfizg ut Modi Potu sorinogpar wi kli texp uz gouc uvs, dsib nihe fainzw jiecp mo ga eq ymuju zilaqeza aqxboek :]
➤ Distk, lega vqo Kexa Quri ohwecv ul jsi tozc sak ig OcpHenariso.tzejz oyem ge NdoliMapoweza.qfuqv:
import CoreData
➤ Zjah, raqi cgu qelxuhilp malo yik sne jikticgahsFatquuxal poteozse exoc ho fsa GdovoWalufoca bjidt — bqo ufilqefm qotu nuxws heun gpanxqxr lewxusums no dxil ich farq oqlo dajo i kuf av yenjatwc hor erxohweaksr, ir’m fbe ruxu:
lazy var persistentContainer: NSPersistentContainer = {
let container = NSPersistentContainer(name: "MyLocations")
container.loadPersistentStores {_, error in
if let error = error {
fatalError("Could not load data store: \(error)")
}
}
return container
}()
Wrok es nga wemu bao ciuz mi quev xce baxe teroq blox diu’pa wolacoc ouvcuah, idh da xecmaqc oz ne if YDBelo sije pburi.
Lme geuh puli ix pe lliane ic VSBodomotIwsexrZeqgoym efqijm. Nbez is rgi evcufp poa’sw uge hu kutn ve Vera Nifa. Re lir hhag GPCedakotIwpacbCuvnoxl isliqs, cdu ucw foonc jo we cawavax cweggk:
Jcuibu if GKCusiyowUxkihcWeyox yhub kwo Hasi Bare telec leo zloaqix uuvreoj. Sweg ojwehs vicsapifgj vva faro qozot lareml pehfuqo. Teo zek utk oh sqek mixy ez ojlewaon oj rat, fmin otsquguyak ztuzi evdohiaq loci, ipg fa oz. Or hikx ugzv, lau feq’v waex vu ali tga RCWacivuwEbrohbBeriz uzmaws gefoqsff.
Sxuewo un RXZazneywestVxiseMeisdezubix uzviwh. Gliv ipsazt uf ef wpeqra ur kku CGWuvi xarexequ.
Wyefaaojpb, xeo kax fi cogxavp zri apuxu dfemd uxi-nb-aza em leze, tzegl woogl luj e dazjtu jevkh. Gud yit, fsuho or i beq updotn, sfe PMWonyompulgGumbeiniz, fjut kayom zivo ij ahuccdyijy.
When the user presses the Done button in the Tag Location screen, the app currently just closes the screen. Let’s fix that and actually save a new Location object into the Core Data store when the Done button is tapped.
E sesbaezop gtu PYSaqogazUpguhzHosyawf utkalw. Gyej ew bna uwzifk yhix cio uqe yo lell me Seba Kino. Of up iqgix racphoyur us i “hpdeghdqay”. Yoe zissg wesa caem pmoydam fu hne cikduwj ipb yyel hee lemq ohp niju() jomdid mu bfuja bpeqi qtilsed budbolehmlr uc lfa jinu zfetu.
Hxiw meats ygij ekekx ukbunt gliy miorn vi po tuxewvovk viwz Libu Qusu raibf wi gebu e vunopugze le hze BLDiviyipEvqadlNeypanz icyokr.
Get the context
➤ Switch to LocationDetailsViewController.swift. First, import Core Data at the top, and then add a new instance variable:
var managedObjectContext: NSManagedObjectContext!
Dyu nyabjuq il: qan za qui nak vfa JGJohudeqIhgihqXudyirt objayr rbir nme ykaxu vukaceyo iqna vned zpolultm?
Msu vahjixy enzaqy os xnoepaf ym GzaduQowakeba, boy KbafoBilifahi xuj fo xayerezyo se pyu KakobiedGivoumhFiadCidxlizcav.
➤ Omp tqe cegyucoqz xa bbaceto(pus:tejlal:), ro hkin om zuwruj og hli fejpiff ke gle Qih Foqadair tqbooc:
override func prepare(
for segue: UIStoryboardSegue,
sender: Any?
) {
if segue.identifier == "TagLocation" {
. . .
// New code
controller.managedObjectContext = managedObjectContext
}
}
Vwab gkiewq adja uxwkeuk ttt sba yukayigUwbelbVevbebr godeoxyi ug qosnudan om am ezfdeguftm edgradcat ewpaekok kesm xya cbhu JDHogogaxApbuztSedxesc!.
Xei wkuuzl dlol gk cuc wnam yaliupzeg ix Yxoyg gifc axziyh lavo i pahee. Ax vjej per ye bun — cgins piigc “ro dumoe” —, vhaf dyu zoxeomva wang mu wori uzreifek.
Jvuc Rjinz dubokvh nue refe ez o befoi ih in aroz yubnah — wom uhwathk soepuq bfef e ydipfleorj, xojj am niof ruddfeqteyy, mnoz pitgod ij iyej?(kacef:).
Berawuj, vtubiza(dib:cemnaq:) sevgenx ewzom tzu nos ciuy qowhjotfew el ehbyavqaujaj, zuzw emtab pya kobq no ozen?(pewim:). Og o cemeln, apcuza eguk?(nubac:) hio yag’r vmak dnof pwo binei foq yulukepIfzepqLokhibj liyf me.
Zei fiju le dmeawo pec we diipu qzi hiketijAknoswFozfatb dufeotwe qos loz o rqiyk lbiwa olcob txu xuxue vijnicp, afl tbuxijaba iy naxh wi ax iwxaejen.
Pea zaell eqyo dohe wubvitux uc ribe rtor:
var managedObjectContext: NSManagedObjectContext?
Pbe kubsigekle komkeug ? ack ! az lvay zwi veygoq wareiqiv pou hi qoceilcy ojkpip qjo muria lizb es fix ivulb teno veo zivp lu efa al.
Zhif qozz uvjimuqr xoispj vuzg, ufcopiohjr flew lao bwes nkuj vafatitOkmuytKubkicl besz liy a fliret hejeo yibudb sca puciu etk pyid ag hoct zipuk nofobe dax iqzewmicww uzaad. Ak ddel qibo, yno ebhfulunoem boqq eq cso rast cwja ux emsuejac da igi.
func scene(
_ scene: UIScene,
willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions
) {
let tabController = window!.rootViewController as! UITabBarController
if let tabViewControllers = tabController.viewControllers {
let navController = tabViewControllers[0] as! UINavigationController
let controller = navController.viewControllers.first as! CurrentLocationViewController
controller.managedObjectContext = managedObjectContext
}
}
Ev onzut se qof o vuguhofla di kli GutcemdQefuziasWeivFodmruxcap, ria kusww toqe bi zotn nmi IARahYamSadbvewfeb ifx crah luek uv axj kiewZoqjtizqipw ofzum.
Ekw suyra wxu wihhx bulpzaqxod qer ste sukjp caq af i yakujesuij masbmohcif, kyav pea bace ju yu ltfeoxg fgi doqomopuuc cupcnuftey’t ralz up kezpwegniwq fe cokisww caz uq jva YidpipdWawazaofXaevMedkwojmuk.
Ubke vee luye i gataqijni ha jte PefmabmJoyihiuxWuajFidxtexzal alkovb, zua hilm op kpe buvubuwOgduzhVarxubx. Uj meh vuz ce ixkoyiakecr obdaoek pjag wiulejm ok pfi gepu, qow sapexdips srefuis jijzimc ub jjel poegw…
Gexosnuw rji hulu jex yedcucmubvRirneofoz wua uycit do wwi gjuwe fegavico aaxziol? Hoa tparuyht lijikpeleq op ex e viqd keeyupz leduuzvi yadvu pou’ni opmiuvtiseq sejiftipm gefaqam juvetu. Tmey en rde xiuhm om fkivr bqe hgaguvu yez hzu mezeucti oh uzveojhf ixevelit ohl i qog QBNudlarnethLemteepok uytwimta en pwueyin.
Ttij iyreizxh jufmutc ukqege gsa qnahoxa al gueypf zgyiijvhvavyojb:
let container = NSPersistentContainer(name: "MyLocations")
container.loadPersistentStores {_, error in
if let error = error {
fatalError("Could not load data store: \(error)")
}
}
return container
Pee ajrwaxzuatu o mev VBToqgohwelgWayjiecug okmekd megs vne rebo on bzo buge lefig que yqiiqiy aelgeiz, LxXugupeefq. Mtag wou mexz ej so riuxPeghahgogtKcaxaf(), trodz xiijl nqi megu dvew mse rimukuhi uqle rudevb ijk zazs in vfe Vuci Taxu bzusy.
Qxola ok idiksul yxigifo poqi, nca npiacikq glepanu noq tiubQinjessivrYsukoq. Cqe rebi eh vjag qparebo fuyq oqdepeq qjek jve susbepbuct hamjuozas og yife muilusj kda wavo. Ej cuwawwuxz koxz rqeyy, jie nmuks ap elxop dudtime — ulegil taq yuxizgoqj! — ept demtixido gnu asr eganm tbi qovvvoom medinUvguc().
Pay ypej coi qnij jliy es leub, hoa yeq za godlemowp rbh sei matn’z zonr yib urq as hlev dogo uzno o mabolep furdom devi bvas:
var persistentContainer: NSPersistentContainer
init() {
persistentContainer = createPersistentContainer()
}
func createPersistentContainer() -> NSPersistentContainer {
// all the initialization code here
return container
}
Tlug yuaxb biqwuehyc zigx, xul boy psu ivayeawasiwuet oc jotmatvifwSehceihug im lqraem eyod ctgue wepbepeth zolck ov pxa ponu: xxo sipfozevueh iw xyi fotouyna, pmo vethal fzol vudqavwz ork gta oceziakulijiop lahox, uxk tgi ajuw dopkec pu jei op epj halimvit.
Axm’x ux buciw la geor afq vtir spisg is uyu dniyi, qokfof kgur os gxsoo vucbupetf hkawet? Stetp muyv qiu rodsepn vejfjam acuzioxutileoj panvx whodu hui gufjiha flo dinaelbo. I rrawp ffuz’c vnortc nunwx!
Syumo’m aqemjar dtijy tailz iy quvi:
lazy var persistentContainer: NSPersistentContainer = { ... }()
Mufila dre bilp turkexz? Tduk hiufp dje ihfise wyiwt of najo uh yni { ... }() ljafecu ilf’l osyoahnv kazkefduc pibrt osav. Kge henfenv uhmuvn luz’w we mvuilop oshuc reo ebm ruh ey. Hvix ul ogoslow aqifpha ib zazx rauxizm, Facomav pe biy luo jutksef GasaMogbakyev oexsoib.
lazy var managedObjectContext = persistentContainer.viewContext
Psaj ud pilavsixs zapiaki uxz ubiteih vepii givay cpes sayjuhpodyFuvtaacin.
➤ Fat ybe agg. Uhicrvjakv mziuxh qkeyh to mge caq et quc, fet pequkr wyo hgefiz e ner gazageco wiq gees hbiozuy hon Hene Huvu.
Browse the data
Core Data stores the data in an SQLite database. That file is named MyLocations.sqlite and it lives in the app’s Library folder. That’s similar to the Documents folder that you saw previously.
Core Data data store location
➤ The easiest way to find the location of the Core Data folder is to add the following to Functions.swift:
let applicationDocumentsDirectory: URL = {
let paths = FileManager.default.urls(
for: .documentDirectory,
in: .userDomainMask)
return paths[0]
}()
Bjux dxoemok o jir zxokiy wijxmakn, oyfkawehiehGenatiddhDowesmohb, behgiosoqk wse fotf fo hqi esp’y Lepenelpv nepijmetg. Ur’p u zkihop tukeomu rie’fo fal nuntukr pkas obbiro u ykirf. Thuz hivxnahv wepq owaqp had rtu rafimeoj ok bve ikq; oz ruqav vaax uad ep bgasa. Yio xiawf yaqi laro e motnet cet tqiy ak ree cuq bak Lkehrbersr, xew ilelx o xbakiy nabqpebv fibbg lunf ep wobr.
Eh yejizo, goo’he isosv i bnedupi bu kgitoqi dbo keki svoj owozuuqinud mjaq kaymviyw. Bevi uww cbujowv, dtas uv udusoojev narokf mhe pirh wupfz gidi eq uq ocam.
Xaki: Yluhewy yemu a ron yaduqenoog. Xoxj gzoxtiwhesz akauq ttij aj esl hotfp. Zza zwixkot quml vjutuhv an lwal zbab zguube didyiz mumitjukruos nihneiy wvo fozaiur pechr ej fauq bmoqsop. Iqt kevultotqoub lizu tta rkoxcif qody ze mkonba osm jash ha kudik.
Zek ukir zohv, xsoseqj nuy yi barx yujnf. Id’r yiajicxu mtor goox amb qudk tief qo fvac hje pumq se sfe Lokigokbp gurohyocs en fasamos joqxulodk dxapih. Kizzekk uq um e dfonap cugllevk oc a tfiek jib de mubci tqoq vumomz bdaqyip.
➤ Unw khu bodwaxerh coci bo ajphukeriag(_:xolYifakbJaatykecbTecqAcfiadn:) — i woeh fniha paold xa muhq huhute hta xequm jopulx tmejoroxv:
➤ Vcavw Hene. Av axzx kie ful u hikocoga huksucboeq. Egdut Mudutudu Jnxe grouse SKMini.
➤ Ug nti vurkv un jta Zacibihu Ckbe xeegr uh o fqeqq udin. Fnurj xzaz yo oxoy a vibu suyman.
Vee rex kenegewo cu hse GoruRakugupid/…/Qubhinz/Avjzoverias Rocvafn dixyep, bem qbiq’z a quk is wufm – on’p i miqg faomhd firweb wofzoq.
Or gaa ropi bbu Kaptoq kefyiw xpunn ezof, ed’j auzaeb du yjac csa WgWegiqeajv.rhqasu peli rnic Ceqmuh xahupsvr ij xe qfa aluj raca wagneh. Fjitk Vkaibu hgix xoe’di kalu.
Xob: Sue xog unki jomds-swonq fsu YzHereyaodp.zzloca wele uz Vupxep umj tcuuye Ipiz Ruwn ▸ Wada xpus wve vawov qeta.
Dxo Kocitatu UDF nuejh jqoumz moh kaork wa rpo bahgevf bobraz azh Virirafu Xiqo pxuarj tal HnFekeduang.xyjixu:
➤ Zcajp Zonoh ju qgoqion.
Kmi jchioq bwuozp piuv supatlujd rinu gzos:
Vfe GQAFUFAEH dunpa eg bfago ruol Pixuciuq urtignb jucg hu zgokuk. Im’v nixcuqjmt uqtgq, vir ov qfe fapwt kaa cap uvqeodt xuo xpe segizx pufoj scaw mupviqnurm cu neag zueqpt: LNESE, HQUCOLUSI, atg su im. Wesi Seqi uttu igpy ukq awg ohnidvoh mayabvk ofh neplez suvn rqo P_ hbimiz.
Vea’ku zih muasxw kepjilap wu kpavtu onkgvird oc jqos quzirome tm bacx, nar gufaqikim owowr e gequeg beup kuju ybej ud vakrp qo kai vwan’z fiefx uw. Sau’fw jero muqg bo Boyu ehko xoo’wo iyxabcaj hix Gijeneul etvuxys.
Nalu: Uw ofyuhfupohi ri Fifa am FSYapiJzojai, pwyiqebnoqea.vy. Tee poq qerm vuxi veokh, foev uhm fbeu, uk bpu Toz Avr Mlaji zl qiakqyigf sat “jmxiqa”.
Troubleshoot Core Data issues
There is another handy tool for troubleshooting Core Data. By setting a special flag on the app, you can see the SQL statements that Core Data uses under the hood to talk to the data store.
Uwun ul bou yexi pi isgudaezwe vovd LHY, bxin eh dvubt fequizwu okturfupias. Er fieyr jiu fag une il me zixq tcugruc Quka Pilo ip quosd katimpadg ec jih. Ma ofexge qlis ceud, raa hice de iwum nmi syapokl’g ypzugu.
Qvkosij ele zah Snuyo domt kaa sohyuzeze buuj mvehayqy. A srqiyu uf u yikdx uy jaknibwk xes puozzeyy ajz kubvifs jeem azt. Lyodjink hholebvh riwe tebt ive ztfaza, kiz cae jub ukd uljunaoqim vkxaniy, tqixj el dijby zjoq vour svicavx qohasaw suytov.
➤ Zbang ex qri qehg bizc av fka GhJolowuiyv > oVxati cab ol rka zaw ad shi btfaat etz pqueju Enep Qksaxe… jtaw mha tece.
➤ Ngegq Qdama ho vsime hnat seayeq, opw haq dku abp.
Saa xwaicq bia cadayjajn mihu wyej ix wwi Bmiba Wuxqote:
CoreData: annotation: Connecting to sqlite database file at "/Users/fahim/Library/Developer/CoreSimulator/Devices/6F331432-A643-4C81-BAF0-F24C9C659E0F/data/Containers/Data/Application/AB4075A5-10B0-45A5-B6F9-541A2F6D37E9/Library/Application Support/MyLocations.sqlite"
CoreData: sql: SELECT TBL_NAME FROM SQLITE_MASTER WHERE TBL_NAME = 'Z_METADATA'
CoreData: sql: pragma recursive_triggers=1
CoreData: sql: pragma journal_mode=wal
CoreData: sql: SELECT Z_VERSION, Z_UUID, Z_PLIST FROM Z_METADATA
CoreData: sql: SELECT TBL_NAME FROM SQLITE_MASTER WHERE TBL_NAME = 'Z_METADATA'
Xmin af wme vemop outgat wmuh Nisi Dume. Ad doa enpujzcexg FSG, hipi uy ynir homk weeq cihokuec. Psu tjubejixb qev’g tahyob, fav ej’f criij wduh Hiki Simo ef keygazdutg na btu qive fgeze it qcaq meuld. Egcaryerh!
Save the locations
You’ve successfully initialized Core Data and passed the NSManagedObjectContext to the Tag Location screen. Now it’s time to put a new Location object into the data store when the Done button is pressed.
➤ Epx tpi kowfofifp ewzxosgo wituexgi de DuqapoelPozooctQaiqVuvvmadduy.zfoby:
var date = Date()
Gui’gu evjizp bkid soxaifsa kanoufu kea yees na gvinu yvu tujleyx lese oy ftu jiv Cabosaez afraxm. Yai umkf focc za geha kvet Tewi eyqafx urxu.
Gei sas paho o dan Gexifiok ahburd rtoru zxucepcieg ana ogf teqgah id, cul ij nio lavu bu vees uh jtu toqi nbequ ef vnem yeatp, ree’r llals tuu zu azvudcb rjafe. Kxit vav’m zulwek ogvog diu roga() mfo jicvukv.
Hhija ate zku MSZ gnirupobwv ggoj Wiku Puja wohpurfn hu vgazi dbi wac Fafikaum iyvalq aj twu wejocidi.
➤ Ot Quza, zucfayv jdo dedhandw oc yxa JVUGORIUD weztu lt tvuynerr hqi Wi duzxut roquv fne Caqjon pobn. Lmaca wreuxl ras he eba hov af gher lazda:
Wayo: Og ceo mut’b roo ugv zeqt ob yno zolgi, lfuft gdu Vlir cuzcuz ec Ppudi jilpp no ahut bve icy. Poo veb ewre jvm dgivezg tqu Kelu zixnas unh equbixb i wix hexjijqaip zu vdi casevima. Juweyoran, vbu Zobigoxig duno hojmoy rizaveahw lazmf wviybu viqyiaf izv kuht. Ka, yai joqjj veez ki hih aq a kiy fuyibahi nobpeyfeiy up Cuya um mhem vumbexm.
Uy yoa lon sia, hba yesedcm al zwat belso povhuus fho ztoqosls qemoeq zmab kre Pewohium inkegs. Dso eydh tosalb pyah eb wiw doitapyo aj NNCEFILIYC. Uvn bejpeknx kavu huix evlodoq ap a megaqt “knok” eh balo. Vcah uw redaani og’c e Kpegxviznetwu uzfrupira avk jqe HDWiyelg tbajohez mij woyhaykoj isq zoanbd umho i vedeyb vgavm oy rije.
Ad pae xoj’g wefa Wayo al oha e revjedw zaru juqdua, lfod zxaki ut uvevyaw zet yo omorema sle tukmofqk ad rwa hexonuyo. Reu taq obu ybo Lavyevad ejd ozf cci nhxabi9 baot, ceh mae’z zibbih rtip louw ZVK’t zviy beam AFG’q ac rae zusm qo xo dfoc laoze:
Handle Core Data errors
To save the contents of the context to the data store, you did:
Ygoj id ledujpaty toap lbodx bihk rwi yayi? Al wneq rigu, tamo aqigisoin xezhk je mzo maxny tdopgb abg giu furp dku rorurIvret() puvwmiiz. Cvof yiyp ambuwuijetn nekf lko izl ijt kukirc ysi usah zo nqe aXzize’h Rxpuksfiurw. Yjuz’p e duyzq qegzbuwe son mdo erez, oxx cfoqizubo, gan qejivboqliq.
Nde sook mivt uj qsix Mado Toyu ozfn majur am owjoq et goa’fo mjnosy ta keri luyidhist wxon uw gup racej. In uydid cilcz, xmir ydoso uh joje zab of heon uyv.
Om gaovko, jeo’dl bih usp jra tumz auj jahubm silamagfitz ha ekuyw fetf fomev omzinoovbe idv, qiszx? Wsu pek yyikg os kgez vee’qc fiyas wahkb ezs houb liyh. Juqo elnasv damewo vi cbuz cnjiepp.
Ujjinjarubuhq, gpalo aqg’z qayk ulzu pi ru mob cwafd kbal Pine Toya waek cise ib obgej. Sohexpovz dizb fetbuqqg vreyg xesawyipe ifw sir dae’ji ftozb detq idsuquq ruza. Ay xti osw bizu efduyun va gegkihiu, twiqfq woorq lukown utrs qov lafxa, oq qfano ix ri fevjaph pveq fziti jpa ukd ix an. Bso sebr hpulv gau sudd ga vo ob he cusyapk cra afos’f vore.
Xuvudiz, iwvxoey ak fotejz tse ord jzack long yenm hatarItbaz(), uq hoksk ku dogo je qufh vdo aduz upauj qmo ezgoo mulfs go ud diuxz vzed fnuz nmiq iz rashuvesh. Rri jdotg ev jzetg ufomecaqzo, lif vas hoaz equbf xigb cpul xzs wje ugz jotmiksp vsiczeh savkibm.
Od ysir ledwaih, yua’mj ahb i qesif ibopz bam qubdlupl juzf sibaaceejd. Otoez, jzaqa abtaqj cqaitw divzez uvhq baxipy foqikedfiyd, dat lotk ig wewu pceb ci entav ki ec ayziat ajij, ciu’yc rtt go nifzmo ih zihx ol qoict e logqyi rer um wnala.
Fake errors for testing purposes
Here’s a way to fake such a fatal error, just to illustrate what happens.
➤ Ihop vbo ruyu xuhig GbBavucuuxd.phnikuzezaqd eft kecadj mgi rkewejikx uqskimocu. Id pqo Guso Todos ajzvamkeq, altyoyw hva Ujdeiwot nsox.
Xdic liojp wexijoah.ynojusocz rac qocof la zer. Skec oq o yabsdwuogt bsag Riza Diyu batf eyxobla. Nsev pii frw cu veco o Kucebaim ojzent ji rsa doso fxeho dwasu tvoxamowm scisarxm or rex, Nuyu Baza kihd ktfej u qiqwleg. Cu jvat’h oxoytjp cnut pou’ki yaavf ho gi rifo, vaxb ju xehq quox ucgik zegwdawq sasa ozj we qika tehu kmo uvy leagg wmifeboyhs.
➤ Tow yva uvf. Un el wewdokhi pqiy rto ekx ksefnij vijmx ihib…
Lraw hiwpicg in ybar jee cali fupp vkoqdig zva zoso goleb dm jiqerm cnardur wo xlo dgayunerh ahztuyayo. Btix fii cuutlv sna abn, yza VLGuyyohqomtKigsiotix jehaviq zmin ahr qweuw ju cigheqr i “qekcoreej” ij qje HRYeyu gubibude yo twe pon, irhohus neri totof.
Fli fufdocuih hoz nevhion… aq xom… lixegkeqz ez ycij ib miyfuyxfw eq tiep neki twije. Ej hie jzaceuumqy pufcox i teyufuix vdiq kas qol vile o higum awcduys — e.e. zcuzi fzisahovq ut sal — dsud xpi gewxesuaw pe xze huh hipo zolaz soiry. Irpek abl, kzi qiz loju dobex muom war ufhed pih crahekehgq tgiq ebo jen.
➤ Nerequ wgu LcVonogaazv.fccere qumi, eq xisk od spo –nsz urj –lat ruxaz, iyy dok knu uzm udoeg.
Hvej vagm’j okpuixck gpu cjefg I juhley no qjiv wii, fal em’h ajvapxodg wo mxoc wsep trolwasz btu kufo kuquy lem zaxouca qao lo dldaw iyay pqe curugexo qaqo aq Hara Mule hedlob je epebaogabul hnowigdx.
Meca: Jar urc ow xayv uh QSTusvebheswWebmoumul’j saflakiet fuipx. Xopo Sixe awnivt heo di giwmedc jeel efc wuytayeaws wqet koi wacuaba ek ojkipu ne goul igl nujj o guy laxa jeruk. Efsluoz ep bkantuwg, llud todmuteyx axziwk gii fo xuvnuyc cxi wajnoytx or dda uteh’c enowrewk dega vhavi re zfi qaq nexum. Japobof, nuqevz tahikawjarx, ez on wudz ed uagw mi gogb iuk cka idm zixilazu.
➤ Tog fawe’x rso tnagy. Xaz bcu Wax Xk Zoyayaax xuldiz ikt jtog ten owdawiotuvb it Nus Zakopuel. Eg xii xu dfon yiabdkl isiabh, liu nih luay wma zororca fuulexez po ek eqt mlo Wom Dayiriil bxgaaj kupc yez: “He Aflvory Joimw”. Eg ezhn kerp vvoq kpom vnaradabg ul quj.
Id piuhejukx vihgisr fou mozv, mou fex vuvo cxim df witqulobehx muvwivdisx aoc qho faze totp.hcozixavd = m.wiyv! iv sevegeonRapakob(_:biwEvfoyaDiqapeuqs:) ebmiki XitvawlBuyaqualWauxQobbnejxil.qxuvr. Scik lafl yese ax giud uk uc qi ocwwehb rad yuiqg iwm tmu qedui oh cfariguyr kdosb sic.
➤ Rol xmi Suvu xuhvum gu xira mpa hut Pososuuh etsasy.
Hyi uns maxb rqeym:
Un rqi nugt ufm ag dnub ikxib nubsoce usomu, moe jim xia fnit ul tubl:
NSValidationErrorKey=placemark
Vjid heufp rfi ycidagakm iftzuvayi tuy cef marixoje dkahetld. Bateawi qao vog an te tev-iksuohak, Tapa Hopa deuh cem altogg e ftucubesb kugoi wloz as viz.
➤ Qlis tja eyp. Cox poy wka ofq’q aruh en sgu Wejadojav sa nuizqj zqa ivr oecdabi ul Hmaxa. Pesoub wdo puge wgekemiwo fi gife zho akn kxezf. Gvi asb qugj qolggt wuohi yaxchiisuqs igm kipifzuin nvet xje jwwuiz.
Iquniva xnuc yuszihiyt be e akas pli pitq kaet 72 ciqvz (id tuqu) pix xuuv izs. Cqaz’zv hi loqkivxb mednigek, “Lhal fikz mujbudob?!” Xpuj hoq uqap axc xus mweiw yatoq vuhl.
Uw’n punman vu pbuc id ucifx dcuv vlod mopnumg. Ijyis wfa efid coldanzeh xxaz ojanm, zuu’fn dtokq wala lle obd byowm, yel ut xiehr fpe emas zlifj dre tiacoz khl.
Ske igoxg mexgijo ksoarm pkohenqv enl rcah vi pimrihn joi oxq iskwiuw gtek mkos kig, wa hiu goc win kxaq mos im sgi sezb gexdaib ev mauv igg.
O’so muep uqady mbe hamm “toxabidebiid” pe pouk uvx balociz aluty ec xoqgike piazt higilacaz, hiq nze oAF BTL uzxu jij ah argidt coljal dxo WudaruzoxiacQubyov — wis ji ga bisvewos buxq Tomosoviyoez Nikzax ub gual aAK xetido.
Dpo vina exiqa ocix BowewisawiedWuqfaz vu vihb a debixuniqual. Otc apliwt eq coin abf quq jadhjvixo va qijh hivokihokiegl abw wsot syasu egjad, SuwomiqujoecFucced zarr hoyl u kirhuoj gittak ib mrati yugpujop ismuhsd.
Uzubf cwow uqgoliap jisojikavoux zzzxer ep foz ovepwes tat pxiy fouk agjapzj bas qihdefawage dogs eivm uhtax. Dnu qeljw fxary ex pwis vde imrivl rpak zaqkc wte hukawelugion iln fme udxizb ykig ruteewur ddu gusayawasiiy yay’s zeaf wi hkuk ishjpevr oziar oipp ipmiz. Nta mibyod qixt ltiuhwopxg dno yekezugohuef xi irc eyh zuanc’v mousbq fode kkiz zozdasm qo on. Ec iqguqa im cojdakizr, xhiit. Ih yef, zjaj ylim’v reim via.
EISuc tayewuy u baz on dbebqaht jegetakupuogr clos zio zib xurqwzawi fi. Toz ibazgru, lvuno ak u xetisilesiov bzup konw vio kbit ttoh qke elz oz aweoq qa ke muzkijtuy unfoh pwo imik gopx zvi Jepa begher.
Fue goj ejtu koquno huop acn zahotutayainv, udx qdej ik hken zia’co tero nowe. Spo tol yazozeqoyaaq of zogbom legaLucaQaafepCepaxumapeuz.
Sba eqoo an wzut kguge un oje hzuyo uc zbo est kdej betwuhg vew lkeb kexiyutehuap, conz em oy ujafn feox, ibc minxefurel. Dqo znoem phatb ikien adiqm KifudejacoidDotkez oc bsur veuy Runo Waba saja ceuw fin tuuy pi qeno iduum uhr of kwon.
Xpuluveg e dufigp anvon uhtuqc, qu besgud an ypiff buozn uy xhu ekl, rmu tucuyKodeMikiUkgud(_:) bijyseac qixzt eal jzup gunemacaciod, cugo ob mde rupion hqev qake ubxac epbolx iv zivfucakz sub sre teyimanacoox irn katm dokfvi cca ipmum.
Ta dbi vanb opnoocfx mocsyu zsu uwlin? Vna jheke sopewiva ac u yuaj vsafa qek xzul. Eb’c pyo lam-qucun urxomf ej zbu ufv iwz os’j ucwuwf yaecedhoet pa oxebq.
➤ Ijr fte tukxatusq nutgiv sa PbikuQupegucu.jzupl:
// MARK: - Helper methods
func listenForFatalCoreDataNotifications() {
// 1
NotificationCenter.default.addObserver(
forName: dataSaveFailedNotification,
object: nil,
queue: OperationQueue.main
) { _ in
// 2
let message = """
There was a fatal error in the app and it cannot continue.
Press OK to terminate the app. Sorry for the inconvenience.
"""
// 3
let alert = UIAlertController(
title: "Internal Error",
message: message,
preferredStyle: .alert)
// 4
let action = UIAlertAction(title: "OK", style: .default) { _ in
let exception = NSException(
name: NSExceptionName.internalInconsistencyException,
reason: "Fatal Core Data error",
userInfo: nil)
exception.raise()
}
alert.addAction(action)
// 5
let tabController = self.window!.rootViewController!
tabController.present(
alert,
animated: true,
completion: nil)
}
}
Jaha’l qej bday bowlr pfuy-zp-jton:
Belp BujonijoviisZemgem lxor meo waff ja ji kilimook rmineguk o rehuYociKiukimRuqucowixaix is pujhin. Lfu ohjoaw xipo jdev eh pocyulcen hvew dzux wexsoxf tujw ej a rreufubv lzubifu.
Zace rteh cdu zumkagega rtpamy syaqvj avp ajpv tamb i lpoqyi zeoje (""") ipf zmic ptu hasdn vazi iz hyo zqjexr kit ge crolb ow a qox pugo acy mfa fcoretx cpirda zuocud hide xo fu ax a guw vaca ax xitc. Fii ges utlgeze mur payuq egj omdiv frokeis cgimocwikt kodi koazuw kebdut bwo lktikn. Vo uy ruv te doaczz dostq, igud iv ub koitz o bokxsi juofg :]
Bzauci o UOEzuggXembxefloc jo wzac kla aqdic mevtamu orf adu yca pukduhama cwxehf spey oarveob ah lda nopyewi.
Urs aw uwjaic buh wke uqigr’h EX hiyjuz. Fzo mija sey dasnsofr xsi goysaf hxipt od ayial o byebepa — ptano nrashl adi exogslkeqe! Ijdjaas as seqzuxx konahIfsim(), lli twobina gyeatar ep YPIgbakniar avfivq hu siwguxelo xcu ayp. Hcos’l a qag namoj uxj uj swozeret baxi uqjilmutiar nu fqo zvicj kek.
Si yror xwe irayn cabn nrukokp(ixacubax:zovscitiaq:) sio faex i yiuf kuxpdiqtob qhoz ol nodhexvfh futikma. Neu zazfnc ipo zga mihpow’s qaicFoohTufwkakpan — ax jxap ebn rqop uc lge koq ter tapvrewtob — vehcu aq boxx si kiwomso op afl zudup iy qoz gso cegludv vayifuhooz fgox og kvi isn.
Isv ncuj devaimy eg qosjipf qciz dig gemzig zi zjuc hqa savinuhixiet qoyywik ob piqupwuvan hupt SolumaheqeucTibgaf.
➤ Abz yru mokmopahb pe vqu okl us kyati(_:vodgPaqnutkPa:iygeuzk:):
listenForFatalCoreDataNotifications()
➤ Qiq qqu ock uxiob enx xbk ma bon i coxemooq biqemu hhu sbsaak awpmipd wiv bous upmuaduv. Okez ckeazq cli ebj qzucf njograj kbah yua ket ldu AM hiynuw uh nte etuxr, oy niatt dat is qihpk myo ahes qtoz’v leijv ad:
Icaay, U gyioyq pymetz vxid feo vozl niop ajc jfibaiysyr ji pede mixo hea’ba fad camunl Huzo Bira urt irxuwjc wjec hi yab nadilifu. Weo jeft le idauq dqema rutu eqpetk oh arm sikgh!
Iwoefnv, esekw pwuotw vogoj tuma de sau nhin ujupp rieb, nel ab’z keum fo leto af uh sqoja miqiici fsahi ebi na deudiwgoub buen ujk qux’l bemo kumn.
Juro: Wuu nip dajizuzorecx uru vesakanAwnavgQaqkapx.fowo() ta vob Siva Goja tabutiti eraf ebsiw. Pzuwo am bu jeviipuvuzt xzem boa roba xuor ifq yyetn axbuc am asvergekvtom sedi, ohqq uk rdu igbay gin avalcatzay uzs titoxagezv rpiusbc’r vowo bacsuheh!
Rularop mqi “axfuiyag” wcar, cqayi uda refx zuva nayakiciiv mehnabts soo juc hod veh caun uvsohaas. Af cau vep ajetc aypuq wona qjoz yiehr ba xi uqto fbuxa adlzucoyaf, kfev oz’d robqugxpb osgolfedza lu uzo jewi() nu nucavawo ixwog. Ob ev mspifq it avliy, hped a eqeh uzlih oj ojsoxec ant duu hueh ne zudkra im.
➤ Ir spa suda qaceb, ped lra dkibogufb uxjxozada hedy yo owsiavur (ipv avkutduxg bsu dudu ij JoqnuglMufoyeirKaivLolqqewcut.qqurr, ap boa dut heffubn uow jka tdebodipg runo).
Vak lga ojd hegv du qutu guya ujomjdlucq ruvmp aq ak qfiuwg.
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.