Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Difference Between Managed Object "Model" vs "Context"

What's the difference between Managed Object Model and Managed Object Context in Core Data?

3 Answers

Managed Object Context is the "scrap paper" for any object you have. You may have several of these. Managed Object Model is the data model where your entities are kept. You only get one of these.

Where is this scrap paper?

haha think of Managed Object Context as clay before molding. We can modify it or toss it before saving (a literal setting in stone, if you will)

so using this analogy, where does the manage object model come to play?

The Managed Object Model contains information about the entities. I like to think of it as the cookie cutter, although that may not be the best analogy. I asked someone and he told me that the MOM are just objects (book, store, car) which there can be many of which are unique but also have similar properties. I'm attaching links from Apple if you are still confused.

Managed Object Model https://developer.apple.com/library/prerelease/mac/documentation/Cocoa/Conceptual/CoreData/Articles/cdUsingMOM.html

Managed Object Context https://developer.apple.com/library/ios/documentation/DataManagement/Devpedia-CoreData/managedObjectContext.html