views:

16

answers:

1

I am learning to use Core Data. I have created a data model etc and have been inserting items using NSManagedObjectContext and NSManagedObject.

I have noticed something though - I didn't have to create any db.

So why question is - when I create the data model - is that actually creating the db i.e. is that all there is to it? It seems so much simpler than using SQlite - reminds me of creating Access db's.

A: 

This is roughly what core data does when your application runs:

  1. your data model is loaded by an instance of NSManagedObjectModel
  2. An instance of NSPersistenceStoreCoordinator will be created tied to this model.
  3. the store coordinator has a set of NSPersistenceStore objects which handle the files.
  4. The NSManagedObjectContext will be created and tied to the NSPersistenceStoreCoordinator.

The code to do all this is straightforward and when you create an application project that uses Core Data it's already implemented in your main class. Just look at how the template does this and you can easily modify it (for example change the store type/location).

Mo
Yeah it definitely seems simple!
TheLearner