Key data: differences between a managed object and objects?

I would like to understand a little more Core Data, why do we “select” and search for objects, while entities are “internal” managed objects? For instance:

NSManagedObjectContext *moc = [self managedObjectContext]; NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Employee" inManagedObjectContext:moc]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entityDescription]; 

also, what does persistent object storage contain? if I understand, the persistent store takes data from the sqlite file, but then it gets a little confused, right: one object for one persistent store for the same information inside the sqlite file?

thank you for your responses

Floor

+4
source share
1 answer

Basically, there are 5 components. Permanent coordinator of the repository, context of the managed object, model of managed objects, objects and managed objects. They all work together to provide an object graph management system (note that Core Data is not an ORM, so it cannot think about it that way). The following is a description of the components and various other classes in CoreData that interact with them.

  • NSPersistentStoreCoordinator - Handles loading data from disk. It deals with various stores ( NSPersistentStore ). Incoming storage types are binary, XML, and SQLite. You can write your own stores (using the NSAtomicStore and NSIncrementalStore ), for example, if you have your own file type (theoretically you could write a store to open a Word or Photoshop file if you want)
  • NSEntityDescription - An entity can be considered a “class” of managed entity. It defines any attributes ( NSAttributeDescription ), relationships ( NSRelationshipDescription ) and selected properties ( NSFetchedPropertyDescription ) that the managed entity must have, as well as other properties, such as the NSManagedObject subclass that should be used
  • NSManagedObjectContext is a “scratch” in memory. Here you request objects (using NSFetchRequests ), create objects, delete objects, etc. You can have multiple contexts and discard them without saving to revert any changes that you no longer need.
  • NSManagedObject is the core data block of the kernel. These are your model objects that store your data. You set attributes, relationships, etc. on them.
  • NSManagedObjectModel is a representation of the data model used for your data, which is usually defined in a .mom file created in Xcode. All objects are stored here.

This is almost all the basic data. There are other classes for porting and merging.

+12
source

All Articles