The Most Simple & Bizarre CoreData Intro in History

CoreData! Yes! No! Wait…what? So many opinions from so many places. What even is it? Some ‘databasy’ thing in iOS that allows your app to store stuff, right? But wait, don’t change the data model, otherwise you’ve got to migrate it.
Huh?
Let me be clear: CoreData can be quite confusing to learn online if you don’t learn it from the right places. This article will be an intro to CoreData like you’ve never seen it before: so simple that my non-programmatic (yet amazingly wonderful) wife understood it.

Whenever you start to work with CoreData there are a few terms and ideas you need to get used to. STOP. Allow me to make it more fun for you so it doesn’t seem so bizarre.
Imagine you’re the boss (yas!) and you have several employees. It is a particularly busy day, but suddenly someone bursts into your office with no consideration for the fact you were just listening to Taylor Swift and now frantically trying to hide it. ‘Dana Skully just threw her coffee all over my brand new mac!’, she bellows in your face so close you can actually taste the secondhand coffee.
Freeze.
Your emotions swell at the injustice before your eyes. I mean the coffee is literally dripping from this woman’s face. And that beautiful mac all wrecked and soaking. Do you
a) Fire Dana on the spot (most gratifying)
b) Tell her to throw a coffee on Dana’s Mac (most parents would agree this eye-for-an-eye method works)
c) Think (most Gandalf)
The shocking truth is you CAN’T decide, not yet. You need some context.
If you’re going to be a good manager and we know you want to be one (you fired her didn’t you?) then you need some context as to the situation. You need someone to recall a description of what happened, in what context it happened to be a good manager (if you fired her, just blame Grand Theft Auto for giving you impulsive rage, all the kids are doing it).
Where am I going with this?
CoreData works a bit differently from your average database, and in a very good way, but the best way to think about it is that uses some sort of Data Model which you create (simple enough, maybe the colour of your new ties). However it stores these ‘ties’ in a context, a managed context. The way I think of this context is that everything in there has a description, like the unfortunate incident involving Dana Skully which we’ll come back to shortly. In fact, those ties in our data model are actually written in your app with descriptions so everything is stored properly.
One last thing is that I forgot to mention that you are a manager of a store that sells new Macs, so everyone is fine anyway (you’re regretting firing Dana). Everything in CoreData is done via the store, it’s where the things your create are, well, stored. After the app shuts down, they’re waiting for you, loaded from the data model, passed to the store and into the managed object context ready to be used!
If you’re not confused, then congratulations, you’ve now learned something useful about CoreData. This is in fact how I managed to remember it; I made a story. Don’t believe people who ‘just memorise’ things, it’s always best to use a ludicrous story, it’s how all the best people do things.
So in the end what did happen our Dana Skully? Well, bizarrely you realised that: ‘Dana’s been gone for…10…YEARS’ (Joey Tribianni reference for the non-aged).
Spooky.
At least CoreData doesn’t pull bad jokes like that.
