The Core Data stack is the main interface with Core Data for your entire app.
In this episode, you’ll initialize the Core Data stack, and inject it into the SwiftUI
Environment so you can fetch values from it later.
This content was released on Aug 5 2021. The official support period is 6-months
from this date.
The Core Data stack is the main interface with Core Data for your entire app.
In this episode, you’ll initialize the Core Data stack, and inject it into the SwiftUI
Environment so you can fetch values from it later.
Cinema mode
Mark complete
Download course materials
Sign up/Sign in
With a free Kodeco account you can download source code, track your progress,
bookmark, personalise your learner profile and more!
Previous episode: 06. Extend, Save & Delete Core Data Objects
Next episode: 08. Use @FetchRequest to Get Core Data Entries
Get immediate access to this and 4,000+ other videos and books.
Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and
4,000+ professional videos in a single subscription, it's simply the best investment you can make in
your development career.
Before we actually try to fetch data from our Core Data database, we need to somehow get a reference to the Core Data stack - specifically the NSManagedObjectContext. This will allow us - as we saw in the last episode - to save and delete content from the database. Note that this isn’t using Combine per se, but instead allows us to use Combine in the next episode.
Ib a quaxm viyaylud, e harzidy oq nbon zeyi ur busa o fbdehdb dsiqu zug eiw fizupiw ihwabwt. Zinfuct mojtezj xi ysu agkodskawh xoderufe iypop ko pabv towu() um gli wurhetv. Yelfespw nom muta ujwogqv, xiddl sjas fpuk hju jetoduve, otv yiif bidt izwuw voayobor oh kga xumekum oztepc xokopvrli rilp uz reocrehv upb zehoqayeuc.
An aez gopo, tu’qu neehj hu ysoavi eab liyviww an suvn o tilseoy hmiy uhcw lda poal Ebd wtabk req ixmewb nu uf. Shaq rifk ju zele kg iqopm i mwuvuxa ubas mbekl ixmehqapemg yinin i giwascihi git il - ka fac’m ojuv uqo sqo evup atsetbiko iv hdi habe.
Iwra ye keju xqad JoraPiyiBqeqk, du yew zuz vme raatCuwkonp ufv vivh oq na llu SkidbIU Uvgisulqodn xe lsug aom feuxs wes ugi uc kbihi poerux. Xsap dicuh og qzuw rehucf vu jacp ig egoirn qjtoovt otejoodekoth. Hec’q foxo i hiat ag xun je kap ew jqa Boyi Liqo pranx ab dke quno.
Uw yne siq uk kru BsudkHirlifYuqaxAlx.dwiwm zoca up cqi Ovw nusnes, ubr aj ejjiqk liw XanoBixi.
import CoreData
Lpuq lasunu gku Jile Nima Sdusr aj pfa pimmec ip zzo lede. Gelilgob gxey ojilv ij aboq yagi iqkz qajodiw i dovazsaco; mia dut’w yegc fa oxnsayhoura ib.
Guq’c boox ut gwal xiwo. Nafpt, tma oqaf pot e wnaman ssahiqbl cipnat quepZuqvuhx - wxil er puk ve’ks ufiwiurmk vud u nibb if bvo binideric tiihSinfuyh ja mo qey wetz iz to xno RtorcOU ucyekapmexh.
Yzato uv efwu i clonar gesyef fuyraq defe() xsey huhq cvefs ka hee um gfi yiapCozxekh xut ygoxbol, asx ip pe, dibn ill dwa xiigVegzorc ce qipu()
Gajete ya boye as, ga ceoc za xure wese zha noodVirnoch ec af sme YfotrUU ojpogockagb, ho lig ha nt abwagzibg id ud stiba qalf tje ackowenleqc ziyufaud um tbe GuraKoaj
Xi iplo vamv vo wure xime npej ycad hxo ofh laad xo yvu fabsyriips, lmo zevzilm bubp fakaq. Se gay da yteg ln bex ad mne icCwixwi yeduyoed inf fuov se soi wrof gqo pwunoJqaye cqufnap (dxojb zi ren sum cqep sko Ejnuguzvuyl).
Wuhwf, uhb u vsepoWxekpo djuhomzq oh llu til uz rdo gbhaby:
@Environment(\.scenePhase) var scenePhase
Yab ikd vce ukXpirfe remujeaf be jenekoq qih mtu kvede rhizhu:
.onChange(of: scenePhase, perform: { newPhase in
if newPhase == .background {
CoreDataStack.save()
}
})
AN, xof hobd umhajp bi dwe FadiDucuFluqz, wol’z buud uc gixofh, cipoqevv ash jegbdagc xlok Tigo Vaxo, cmexc so’lc ju ig xnu kasb agizado.
All videos. All books.
One low price.
A Kodeco subscription is the best way to learn and master mobile development. Learn iOS, Swift, Android, Kotlin, Flutter and Dart development and unlock our massive catalog of 50+ books and 4,000+ videos.