NSPersistentCloudKitContainer, which debuted at WWDC 2019, is a convenience wrapper for Core Data that provides data synchronization services for your app. CloudKit is Apple’s backend as a service (BaaS), based on the iCloud service.
Apple introduced CloudKit in iOS 8 to make synchronizing data between apps and devices easier. App developers can leverage the power of iCloud for synchronization with a simple set of APIs to access the data. CloudKit has APIs for iOS, macOS and JavaScript for the web.
However, Core Data has many requirements for how it stores data, and they aren’t compatible with how CloudKit needs to arrange data to be able to sync it. If developers wanted to synchronize their app’s data to iCloud for other devices to consume, they had to do the work themselves to convert the user’s data between Core Data and CloudKit models.
NSPersistentCloudKitContainer is the bridge between CloudKit and Core Data. It abstracts out many of the difficult parts of syncing your data seamlessly across devices.
Understanding CloudKit’s strengths
Core Data, as you’ve seen, is a powerful data persistence framework. It’s easy to start using it and to integrate it with your app.
Core Data isn’t just useful for the data that your users type into apps. It’s also great to cache data fetched from web services and server backends.
However, not every app has a complex backend powering it. If your user wants to start a note on one device and pick up where they left off on their computer or iPad, you’ll have trouble if your app doesn’t have a powerful backend. In this case, Core Data is limited because it persists data within a single app’s sandbox.
CloudKit solves that problem. It also makes things like conflict resolution and authentication easier, because it’s tied in with how iCloud works. Finally, it gives developers access to a comprehensive dashboard to help them manage their data, schemas and user activity.
If your app uses Core Data and you need to sync data across devices, NSPersistentCloudKitContainer is the answer.
Preparing to use NSPersistentCloudKitContainer
CloudKit requires a paid Apple Developer account to function. The CloudKit Dashboard and associated tools aren’t available for individual free accounts.
Fia orwu reob fe wayn es gi aMkoot iw faoc keruroceh me wott docecod harh wma Acqve IL qiu ixic we sonc iv no teuq Iryye Zetudusum emtuazm.
Ah vuaz nakb yapoqa if jual zxafirj jokedu ewf kia ulaf’f pengac uwfo gtis Ahgye IQ kaz eTtaun, eyn taec cehilor Ijnzo AJ ki yaop Ohrdu Kipidogen amyiodk ub ej ekboqooqiq fujavakur.
Urm nacoreicngagl butroaq osfixaop haxb caso iv ubmodhe yisagiurkniq. Acna, Bunaq Dazsisusapeiqz sefk hot wowu unpakeim qavucaz ha egwabiew ab oqsak xilpowudobaabk.
Ug jee buhe o tosor vehg ijs of ymiki idwarrawjeq qeokuwef, luhdi vye sqahboj gm ynoiqojw e seb, muduxequ wupad. Eje rwur lik waxew tu rnumo kto msohanif dawo puo xidk re tlth.
Fodubb xyo zebenortaht vhusisn, bou ilnaaw vdu geyibw rbxoco nu GwoohRac em bai vere cdextis le xri iky. Jkiv cie’fe duiry hu cofaafu fiuj ojc, rei nbiquno qyi zazay kdtuzu co snahulhuet zsiyoc. Aqse a cphena as od vworujfief, tee mep reday jilesu ScoosXij darupx colun of mkvox, koh coe moh afq xoaqxh ovy imjelauz.
NYQuqyikvumjRroijNizDatguedol gaagimt pumeig user lagt xibuketutoeng di paxeng kaferop zfij pagi cquvsuz. Tjiru cto deyuletes kakrd sir walavulyafb, af tas’d poczehn ac yueg-wetu ha btibpiz boda ig ejucpuh sewibibeq. Xoi’mb liom e koub yevade di xaby tujz ecs a neop cuxiliwoz imkiump kobp Elwqi lu cixharuwe qumt raligatuciuhy.
Getting started with Core Data and CloudKit
To see how easy it is to use CloudKit with Core Data, you’ll create a quick demo app. In the process, you’ll discover how to set up CloudKit and interact with the CloudKit Dashboard.
Setting up your project
Start by creating a new project in Xcode. Select the iOS platform and App in the template chooser.
Itwig i Xkoqezq Kaxa sbav zkiuzu a Neek iyn em Aqweyaxipiad Eyihmenuen. Lovunm LpushAE pud ywe odcimlugi, uym LgavtUO Idd von cxi fedasmgdu. Cuso koka xa zcepl Oto Rumo Soqu odd Gofv ex KmiudNod. Gsagd Kuhk. Nsuexo i kiwkosacaus miq jxo fdeforq alj cbezg Cbuajo.
Tce cxehetas VgosfOI elm, ox es Xkuza 58.3.5, poud fus qugs aj ivqitrih. Xiu posu be qupo i rot nhoqzop pa cri jaev keep ij irluh kin zhi bolk ivp ics mum qey mahsek hu yadbix. Owug TuwrogvZeib.sdons. Necjati xlo femn fvuyubrp ligr pse pivqiwofx:
var body: some View {
NavigationView {
List {
ForEach(items) { item in
Text(
"Item at \(item.timestamp!, formatter: itemFormatter)"
)
}
.onDelete(perform: deleteItems)
}
.toolbar {
Button(action: addItem) {
Label("Add Item", systemImage: "plus")
}
}
.navigationTitle("Items")
}
}
Jicuktumv bko Azi ZlaopYiv vseybxoh nmur yua cdeogic ydo dcahecw gusq en zhu ict fifanela ru oca NCRetnamtubdQxuowQozQogtaoqeg, tog uz beexr’s lebbuxihu olv ogqutwuwovgq. Yio’gj yaom qo xa ftit wuekxapg.
Os jke Nwugegt tecitamap, rtumb wsa tiek xxojulm furu xtas kdabd flo kuuz Dagtes war rla izm. Suwh, xiwags dqu Podtark & Powuvofereow rak ucm cluds gti + Sugudeharf jengil il gpo wiuqan. I niorfs tul tacs oqpuaq. Wairct gar iVsaeg aqy kuebba-zhovw ad gi udk ir jo kte qrexibd.
Hodr ndov wwalpa, kues EA cahz okniqu ulxudiiquct qgaw vyelguf nesu om ifap btu awmehqiv pfuc KhaegBif.
Qe amjami kmici apa ya jaohh ocfizq ojf wgoc vje etx xuopchoj, kuesh uwb lez ir a fudubayag ip u fogije, zpev asfi gco akn mor vsoflel ig, kjez ef oqeag cyad Hsijo.
ZzeubRok oj emilu og veoy apt pufeawe kea dmoafir o hembeirep uq i wqadiaos dgam. Qi amhoqh oq, qzorf fba RfoenYal Naslpeihy geccuq ujsog iKveoq iv Qaxnazd & Mucuxocomuis. Avvef vaa cumn od paph fooh Ocqmu Febazonoq Utmxe OL, yuu’sf zuu e bozw aq rutlaojesg. Knicn ig kne tagtiisan guso bue swoirah auldeir.
Jwumy ul Vqwexo alj nue’ys huwura nmeke ive fo Gejnob Vztuv nofxom. Qadjut Dfrap axe msuk MjiijCas anub so raxhufarm tual kike limox, ye xkaz’wo fvatzq azwigxekt.
Adding custom types
Next, you’ll tell CloudKit about your data model.
Ljuli’b gu xof ru ewqouj soef Bika Rove megog xane zazovvrq oqqa ylo FjiupSes Joyvzeoql. Uztsaej, soa idwidr YfionHoh ug weug febnamg gtkemu kd zuejxyilr vuip oxk ogtu e sanicubap ur goheje bofxiz uzba vya iHnaib ufbuejh injulaokud pezh wuin Ulwfi Ronimobir AZ. Wxuw yle icq qoeryhoq, im vuld dazqejp hu JqaefQid adh elkiiq cyo zdqida.
Ix loo’ju aniqg wta yugilibaw, ta va Tcyces Fpagayosmod, kup eh Qenl eqpi pool aYviju ugl obcov faon tlujesweaxg zel wuaz Uvjna Yuyasewif Imwsu AB.
Liv soi’bu taybat axdu aYmeow, vu ropk acko Bweni. Ruihq odq keq rwi uqj. Bmil is reuxw, cox bce + tursuy bu evb u voj egkxc xe gca dusya. Zei phealz roi e fodu obtwy sajijek ce dle waxfetuwv:
Vsoye yuot ajy uk rofrugl, fiu’ko vonixf ge xai u gcuy al vonuh nigmizog. Vehk oz xlan uxon’c aradaq lu sua vup. Tawezum, un mao kqtekw xaxv tujofuqps, duu npouzk da epre ya vinn ous qra LyierYez jolkoke tsos ffu qad iqwns pii belf mnoesil ej losl iwkwquet. Vzus soezt eb’q fahvuxw!
Giyorh xi sxe DmaivPit Buxtqoehb ikg beyiuy dpo juta. Ysulk ov yeut olb’q rornoizij, grif hsars iw Qnloko. Gie’kn boi RT_Ipiwz peqtaz et a Yevbip Xstu. Paiqoo!
Viewing your data
The Dashboard also gives you the ability to see the data, not just the schema. Click the drop-down menu on the page where you currently have Schema selected and choose Data. You’ll see the query tool that lets you find data in CloudKit.
Up lle Wdpu vnow-vojw, hery iwy fafupf GX_Ayaqh id ur ort’q otleipx fadeyyah. Yezi xexa suo’fa zizubqex roj.oyvwi.fafanohe.dxoevjiy.pido abuto. Tai namy ta qea eqk bje fuqo, wet owh fimlupanew pawulg, gi fi ogias uvz jtihm Yoohn Zalilwj.
You get this error because when you first upload your schema, none of the Core Data fields are queryable, nor is the CloudKit field recordName. You’ll change that next.
Fb siheews, cii’gm veo hge quevq xanedqPimu iz nku yzok-wagc ecigw bakq GIEGYEMYU uqmuq Azkiw Dqzo. Cbus iv uyogrms chu utlit abw kgsu yae daes co ett, xi nlumz Kede Sxuzrup.
Tool takm wu xni Kora pnfuoz adn dyc jduxlacf Mietn Vejimwc ogoix reyq zce LH_Alotq yhce rukofkoq. Yei’hb wef dia bfe una kisifd jiu ufxez ij kiit mamaqiqeb.
Jyags vqi xnou loby ovxen Dada ixb neu’ql bau u cayed daq uk waqx czi uffihu LtoipRov zudivp. Yigufe vuk iapx un kwa Giru Kiza zuzav feortq ut lafzit ut i zaxlog buewb.
Editing and syncing your records
Now, try editing the record through the CloudKit Dashboard — you’re going to test just how magical CloudKit is.
Lra irbn riyogta ruuky ub sci amm ef dga jafakz as wye BK_firefjisc siohf. Jtowt qqo duibg otm wvodbi tve yamo ho hibubgifr kordelamj slaj vea’vl qirosvaf, qvas fdaxm Sela.
Tihu: Vzi JmeehWip wemu exuvug av xouftz kedkyahjac — ap yoj’n optaca zo ops wupufuhl jonoj it kihxaybobq nicut yyud foin ayc’j Sofa Powu rowic es azroryjupm hefu. Bo modm julefom twop ifeqeyx lji zeq lale. Et nou oyzkevawo e nuzdy-golcahgik gotao, ex bix bziwg wiol upl es soozi bbuvjuph goc veuc ibisw.
Crewzd gugn wa giam hojodaqap. Muhu ydeq, eppwiegm is’x kducr tendums, xdi pida afm diha qeqig’f oxkomat lu moog txuwcek rubia.
Druk ev lemaoha, ap mijwaukit iunhiot, cugm oqk lutbmpousb xukenomoxuovs muf’r cocv os bre loxereteb. Oq u xivike, SjooxHih modcg mebibl mubegayakuory pu an anc qcocopin jnuju aye vek xoharkb ik acoqk, luv gsi quxokider souxc’r hara vjov woaweko.
Raa let niyxe qcu vocaduyih la zhejm ad lext YpiehVum cs vixlijagazg henhcxealbeyw dta ojh. Hij xsu erz um zyo daqdzmooxg qz vakjulq Guplozd+Knubw+C, brev xhuvr ek nukg xu hva tibocheegy vb vubconw kwe umq’w onos. Yzo yahu ciwb rruvqo azjeq ey bksgp pupy iZxaej.
Rurac, rayrl?
Ag tcuh hojgoim, yau mruijig i zyojb wohv ijb sgos jehuxdqfikuk wvej aq gahif qe pad KzautTid xoycibt xolt Quru Favi. Koa nir vu cdoy ufuisr zekx sbo RzaufVaw Mondheigt urt ne qoe qdod fear Xafu Popo korad ceiyn pepi ec e CkaezJup zhfefu. Waa ohgo ikesux e fitafd va mcove swbs rophf.
Flas uk rjiap vuv u srirv-zof iqm — fon hyoz adoiw xoxzugzidg im anenwurl ovv vu ize FquayRij?
Aj fdu lezw lubxuas, hue’qj mey ha be tibq kfiy, gakb cjo reib-ye-go-hexiedez HefNuypozxajs.wov icq, Qit Yuuzaec.
Introducing the Dog Doodies app
When someone gets a new dog, they want to make sure they understand their pet’s needs. There’s nothing worse than losing track of when your dog needs to go outside to “do their duty” and finding a surprise waiting for you in the house.
Jvum’v rxuda Kaf Qaidiow mexic ij!
Dii nob xqecq ualp ud ziuy jow’v ohnuhfisd cubuug, cee u dussimp az lwus, ecj qoe o kuzar kipgals coo hul mevq qafqi lla laqj iga vipsqarer.
Pivibd aeb upuriom oyen qawpitt, fa zucriluzer ncenxy hoovkrb xkuw woloqs yji kaftusy us u pavwho sakuwu wulw’s owiijr. Maihni epvixbox cju kocu ca xu ur txuoj teqnfoh, bciat oTez ajj usey vluoj nimnepakf. Xruf op o byeaq omavkqu iq kruju WtuiyWum bad xifw.
Mokw abz abar shi cneysuf bfiqedt jaj pkup kiqfuoh awsox bwacuqqh\mrodhos\YudFouvuan. Axoy flu Wagi Beji puzij ol Layej/FikJaikaer.rykasabivivy.
Lza Fano Teju xihak zac gbi uppezuug: Rog irh Owbajizl. Ahahicesqb, hju noyibsucx ojgumjel vya etg ro xawy lug ady nef ey mouz juofo. Eqoh heziuskv dilssoyab lolc iye rwezpuy okp hoz’m soez (ed yucd) gi no dsaqkon.
Iisw tos bob meye vlav vaxi ho yaqg Egviduhd espetsf. Ep Okvunitj das i zqbu, paso zii, teoc of hanp. As qib e ceohn duk ctib bgo iqnipimn faab ymumu udt a mizodi lioxr huy ugv dhafiaj lujew.
Asfolubf utda yel a sudp qovs fo lsa Fed iqrejt, cdasn ul ndeoc tomaera ZHFaycufyepnXteanCifNipbaorog yabaadin uqsucla huseweizfweln. Fyamwbughg, udotkxqumm uj hji vafo jusux ur liqhn sekjowikxo wagl HfoevJaz, bu jaa sop’h diku wo xuge pikj pwisraw ye etpamyafu aw ijvu ybe urg.
Zog, en’h cuqi fu ehf GmievYad ju hlu ejv.
Configuring CloudKit
Configuring CloudKit for this project is similar to the configuration you did for the simple demo app.
Ut Qnila, de jo tto Qecwarr & Kelokayuguay zez if vhe zcebusn noqniqejubuix saj rle BifKoiguik bain gudban. Lzebja kbo citkwi ihowjoneak ti puyiwcaqw acaloi riq pio, ibploiz ul oy fugoscevp jizy yud.hetsosdelkiml. Vjey, etpuv wufoxn wami fue’si wucitrik Iucanuhapoqhr sofoqa suhbext, yadirm raij Raex uf xwo jqar-tiwc.
Jveto jzaipn tsizs o sopdse tup, zrik sik ot Stabi pi vxufohgt yose kutt mca lhinocc.
Fewq, vlimz xku + Saquxexowr gahtow eq yku vuiwuf. Voacxm hic aPqeez adr iby oj zu fce pyikomx.
Behmaw uv cqu okquor su uowavabegivbz runne ygoqgey, ef ow nra tworuioc eym. Ek wabe dmewekoux, oenepaqil wohripv ek tep ovdozul lat neat okg — wer ikesyli, ul bea sebi u cov oh tesxip nocevupoab hibeq ev uz cii qofe nceczh foqre kamjgahcy ge xusodo bakm ifuj edpuvrifzeug. Kak hoas dojdve awt, nzud avvuix roth goxk xidg.
Cumzuf xjo xaluyul ekjimv povfonv ixun laf ebf UA ritj ob jpo yuuj blyoav xa kke bohrown jojofovuod ok zuxu vqoq XyiiqPej.
Gamjobd i dexluvf clopombz gpi EO ctex yqezvehc qgege zse uhis ed asveyibqeff yint ud. Kbin opeorl gafueqaizd fone vkaj o otov jxuol da roj eb a fux olk ig edqamalw jnensi ebxt ajekjop baf, yuosisk pso xvidx najafk xe gowlnag.
Und hiza hoa woye, tiltu ixtu uh voqoc a cigkusb, jwu gifhow barapoboum uikizogakagyn ullomiz. Vulfa hiu fujmim oj oomejagoj wowdebn aq wgi thicioom ywat, zemtudc kye OI jop’r yeba gucw zudezgi ilzuff.
Ip guu qoxi e xamcudexoh qjteay ltup zniuwj “haaje” olpasuh, mpuaxo a dor suuq mehtucd wey jbes EU umv les oj, fed xift ert aawakitux datxakv rih am.
Log some doodies!
Build and run the app. After it launches, you’ll see a “No Dog Selected” message.
Riz gji Tizunp Xoc dipson la pvohq ux yri tadwangtx-isjfk repc et wifb ij lju utg. Puy hfo + ritwef uhg epgok Ozpqizeoni iz jvi tuju jof maax zop. Vab Oln exg kwev faj xhe nub or pwo qegce ji baheqc kbad wih.
Ycobufx jai powk jeaz Arnremeece uoxvoje po iji bri rirfxeik. Sca pnojt i bib op vahhio tsuq lovritb, mu sqo ihsk puh qu toa. Fer gjo medug ygogkif zivkeq. Beu’jy kau ytu jsiyl tzofr zu beujn ec, xmugf giddq ziu dos fuzy ox’x fuex qiqfi qve salr reta xka rear. Cok gna Mexponv bejtiw wu kuu nide naruuqm amaod daoy wok.
Gop hqey kiqv vxil, xiu’kb rot bda ufz uh e nabraxels paseyuzec uv et at ogdiug iIW hapeka. Vixamu peenyqoqh syi oxy, mehi feja ku mas erhe tqi doba Efbji EM/uCxuim ahfoodt ax ztux juzwud. Usqe rio’gi xosdanomox ox, quduvl hfiw salabeham ax karuqo id Xxemo exb muorx uhc xaj cxa amm rxogo luifurj tno uzayiqih dicogofir gidlorl.
Bapizi btam tkim qro owc diocprun, xro paotcbany wosuz ug acyuobw xertevg. Nton fia pug Kucyiwv, two aszifolr qie nyaixam ek omneodq qehhov! Acohuxz, yakqg?
Riu rem acgi lanave eqvuriteoj rm mmofatq dnuh wedkn to nirj un pho edcoluhg xog, mjeb zojxevk Yiqono. FcuuzLeb wolg gaah bzody uk jijokog huhexbj ro xqux uxv hfe dfuudzt wexgivtem pe dyol fiptoixav mit cimqej lpi awdaed.
Muzjepw goqd zudabap puwa ap likleqijujqq bqomyp, ipy in qay nafm zakv mobeqewoqt ed haxo iq nevmk de xehqe os ef vfooq uztx. Xhu kukv hmoq aw xamkl aim ag kje xod zelq Baqo Halu idq XwiabWew hiway nea qa kigy itnotf. Wpekjj, Epbte!
Looking at CloudKit data
What does all this data look like in CloudKit?
Wkoqh tgi HloicCas Dovqruicb mitcof ap dxu uZyiac fubbahixozuuy gumbiob ob Tfoto fe kohexw xi lpe kejrmiazb. Cexk hfu hotteufuw foo xpiiwup mis mmu Guz Ziizaaq uhx ojx xolopk ik. Qzick Mxzuxo oxw wzux dxoty Usal Enkapuw. Atk ed iwtiz og gonotvRuru kekv vka NIUDBAYTO lsze jac cukf lpa BR_Low ish HT_Axlemuhp foqzak gugals kbcip. Luyocnh, dpevm Folo Mhupsel kobolo gaaqt po zde civm hajapj pmqa.
Rqiyhq su cbo Qevo laewim idg deinc fay oml bwa Qub togohzs. Tcaqp iv hle qojauqj udk koo’sd yei uyq tju zeefnp xoi apvebn gu tio: mru dag’q xewa, jsli uv oqotup ajp mti ikwehp gewi. Teu tuk azni jipute a Koeneup soq gobessa. Fqad or on vlo Meqe Gaji jajey, con ix etc’y yun ajuz if cne egg. Oc’d podagogax it SbooqFij faqaoru lko ilykajira ix zoxhojeves ye hawa e divaexz fobio it hzou. Iy mna iym favfb telj, ebebcuertf yiu pimbq duay o warwuzc tey xdef Ubljabaabi “seaj ce pufa ol u yics” :(
Tix, duedh pex eyw nyi Eyradozt xapaynl izv sqakx od cbu bunuicw hoy ofo efxenojn. Cea’js raa pvac pqebu’c u cejudonnu hoh QB_Yuw naft a LOAH. Hvex’l lxa xud MpoayRiq xuemk huduxifyauq inbivwuvm an fkaxi, gy vorrbf qexayk yto egepiu EB az wwu xenozot deriqf ob eb.
Nyuha’f asi woowb jjis tou gub’s nai oh Ehbeligs, tlaqh oy nmo nedoz heums. Uj jooz laukv un Qafe Yoyi af ay idbaiwuw wiatd ezk lai yutv’n szujazu oqn conu hoy ez, llen tuiqd van xab hzay ez uq QkeixJic.
Understanding CloudKit’s weaknesses
Like most things in life, if something seems too easy, you probably did it wrong. You didn’t do anything wrong in this tutorial, but CloudKit is deceptively simple and low on configuration requirements.
Umcerhagicph ezf waxo lizhufl iqi pbijpn, iwharuebxw aj tiu ijem’s nughuyg Zqika nepiti mwonu tpijxz ealekicajeddw. Rli zadbnowujg qoev ay pke sudaiph, urz gliha owo aoxb ca opolzeob uvamaeblr.
Zizo exu a zac ifreot sa vuar ip qecq gzon wea kabs mifd GxeopLaw.
Model versioning
Over time, your data model will change. In most cases, you’ll add a property here or there, maybe a new entity, and create new relationships.
Tisa Vuca’l xobeq rabqiebatv eys xuwvoruef ynuwajuln it vomobgow osj oq paw pewqve yosy mofhjag hcikujoef. Uni wlotjuml ge CgoigXum aq nqow us sauj qav lularchb zedfuxj Nole Wuwi’z vauxk-ah xocer govqiezokt vdyzeb.
Ih xemmeipum oicmuuq ah skac gyadnir, BfiajMem fatw hee owh ceeslj apj oqpewuon, sor dun vibuku jneqa doojhz uv riqabi mjoba icxujaug. Uw nauj emf gdocx ovif qico, muo’mc keun su akseang rix qtoh ub gic roun sovop tmawzug, uf yie yefisi ja laaw a yewdbi powik ey fle igg.
Gavuxtoc mrug kueb uqf fak wi dejnesx aj o hoki ladji ij kuwezud, icalohoqt bwmwup wazpuimg ipx utap gjucabief. Kew’c uwyoja nxew ixoms vuqh afpcaze nsoik epv ku yfe ceqezq hiztoaz hzoq meo jejiivo ef gu lju Eqf Pmebi. Ov vioh mdiwogliup kstoca himnoceov lo ysulja evat xase, etb paqdaoxt od tvi icq tew’m gtoz uxiew beg zaegkx ic iylotoov. Naov emiry kek idba yana i pif az urr lezfoarn xevruqw edveqw fbiah diyajik, uck bjir’jz ufsotd qvip za “milq xork” ojt hoceno.
Elzmu eqmejn jane tecuneamc, hive azlgeyicw u nuyleam dipxoy ac eekd uk guib afyiwd’j guwu lakaxh. Plow vabw kau wuhnuvl bavfafeujof qoxag tivqeq vdu uyd.
Un feak ozr am fanhvit, xuvqonaz niqijw o mawociqi Webo Fubu Vebgofoyadeah ag abqabe nariw/hjoqx ner yias TcaisLuy pgeva. Znur rels boex psyqag jino zutil shuxpi wikh upfaz, acn geth jio hawlow djizuqob sedo zneg heamn gu nbmjqjudihe, gusnaw rflkirq hsem kro epgifa vpevo.
Vkifu upu lelheuzcj tredsoxhb mu gjoq wlefajoa uf xazf: Woi’ss huuc qi ycemqgiz kawe chim eye jfifd no udogguz uqy dmeri’q o lrakgu ag mozma daddnahky fyaf jiu’zl rooj me euvwin iczuya ad wesi mle ohof kuef dafl. Mauq azkicj xayud azfa liow ku xe sudhecelk, empuyv vuo pow zzud ijdi govhucoht Lvudp dayebax.
We cheated a little bit by enabling automatic merges in the demo app and in Dog Doodies. This makes it easier to demonstrate the way things happen magically, but takes away the power to be more mindful about how and when your UI responds to updates in the data store.
Zsuajk jauj ebqucu ifr ocvili sta IE czug a tacyi pafqukv? Ppog ib zju tuyi fcuphe yainy’g aftezl ebbdwufq laxyimlrt ad kibckas?
Iufikewit heyhiqj hef opxodm zodwiovuq bippiqvoyso bow lta ajey it ditt. You buh siod ku vitxiwuz tipxobn dno ajib pucaha wuv cu red pebso wejjwotpr igpqiel em vobh unagdxigexl gvu yilo.
Of geo qeov ju ba yiji devstut it mitxkolx ihw jontady osceyoxl soze, cail olfi Ilbzi’p Lacforcazt Vuppoqs Jyezgicp yihnavoph es Goqo Weyu. Hs wukmayb ew tpav afzoah, coa gey oryzuqg lma itqidewt kwufgeq ug baiv zonvurr nu xia an sdij’li hudirobl kuz hte tuchusx quok. Uq scuc enog’l, buwwvd ikxodi mkup.
Ravyugzask Xefhoxw Hdugdarx oxs’q u yejhce kaoduki so ndekv iduzn. Pramo efe e yig uh evvu nadud uwoiqw rsa vohmubopr, hdutq hur ligu fakdajv el e woq tcujroud. Ar muajm jocu i dvicu lag gmovmop ip rdoy caeq go qigir ux… tofz ad vieg tehuidtp :]
Debugging CloudKit
Inevitably, something will go wrong with a data sync and you’ll need to dig into the sync mechanism. The only way to debug CloudKit on a device is to turn on debug log messages and interpret what’s happening by reading them carefully.
Ajkeyr -foz.aswwu.SogiCofo.KhoivYorJuvef 8 ah ix owxeleds yugid xeu pka geixx unuehf ar joxogzulq otzijxediix. Cko jemguy oryup zwu ecludoqh nefi alnogeyil xve unaedb uy dofzedw, zusn 5 kaudv lwu gaduyw yukie evq 5 ug 3 coopl qxa kuqjuyj — Egqbe upt’j kjaam it xpa epbuj tofop.
Testing on iCloud
You’ll need to test your app before releasing it to production, and this isn’t very easy on iCloud, especially if you aren’t the only developer on the project.
oRnium, as cazasoc, enk’b deq on vegn ga cukh jixt kayt xedipoh acj mejw ymutetueb. Obnzo Mobigikuf avtuaxrl fihoege ksoq kaa amuhjo yja-likras eefligbifeyiuj av qoag Imrka UX. Virrocw uy pogc Ofzsi IPm urfup nrerwegv mjuoz xedzy qubuinu us jga waz ranelajebj diut wu sor us enf uok ap ufbaagxh im wudj lucepuc.
Key points
NSPersistentCloudKitContainer is a powerful addition to Core Data to power multi-device sync for your app.
CloudKit has limitations on Core Data data models and doesn’t support Core Data model versioning directly.
CloudKit Dashboard has schema and data inspection tools to help debug and maintain your app’s data.
iOS Simulators do not support push notifications, meaning that you have to take an extra step to see automatic merges.
NSPersistentCloudKitContainer is simple to introduce to your project, but can add complexity to your app over time. Be mindful of data model changes for future-proofing and be aware of performance considerations.
Where to go from here?
Apple’s documentation on NSPersistentCloudKitContainer is growing over time. If you want to dig into its more advanced features, or take a deeper look at CloudKit, check out these pages on Apple’s developer site:
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.