I am able to create the DataModel, Entities and Properties. How do I now create the DB? Do I have to create it manually making sure that all the properties and entities are mapped?
I am following the Recipes Core Data sample and have noticed a method in RecipesAppDelegate.m:
- (NSPersistentStoreCoordinator *)persistentStoreCoordinator {
}
I can see a reference to the DB file here.
When you create the persistent store coordinator, if you are using the SQLite persistent store type, the coordinator will automatically create the database for you if it does not already exist. You don't have to create the store file yourself.
EDIT: to clarify, the only thing you should be modifying is the Core Data object model (.xcdatamodel) file. An NSPersistentStoreCoordinator object, when it is created with a store file or the addPersistentStore:
method is called on it, will do all the necessary setup of the backing store. This includes creating the file, any tables it may contain, etc.
Creating or modifying any type of persistent store yourself (especially SQLite stores) is completely unsupported by the SDK and the Core Data framework.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With