Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference Between NSManagedObject, NSManagedObjectContext and NSManagedObjectModel

What is difference between these three classes [NSManagedObject , NSManagedObjectContext , NSManagedObjectModel ] of core-data and how can we describe in easiest Way?

like image 352
iMash Avatar asked May 11 '12 12:05

iMash


People also ask

What is NSManagedObjectModel?

NSManagedObjectModel provides an API to retrieve a stored fetch request by name, and to perform variable substitution—see fetchRequestTemplate(forName:) and fetchRequestFromTemplate(withName:substitutionVariables:) . You typically define fetch request templates using the Data Model editor in Xcode.

Is NSManagedObjectContext thread safe?

The NSManagedObjectContext class isn't thread safe. Plain and simple. You should never share managed object contexts between threads. This is a hard rule you shouldn't break.

What is the purpose of managed object context NSManagedObjectContext in Objective C?

A managed object context is an instance of NSManagedObjectContext . Its primary responsibility is to manage a collection of managed objects. These managed objects represent an internally consistent view of one or more persistent stores.

What is Core Data stack?

As I mentioned earlier, the Core Data stack is the heart of Core Data. It's a collection of objects that make Core Data tick. The key objects of the stack are the managed object model, the persistent store coordinator, and one or more managed object contexts.


1 Answers

In database terms:

  • NSManagedObject = a row
  • NSManagedObjectContext = a transaction
  • NSManagedObjectModel = a schema

Of course, Core Data isn't a database.

like image 170
Stephen Darlington Avatar answered Sep 17 '22 22:09

Stephen Darlington