I've looked at the examples and documentation but they all seem to copy an existing SQLite DB into the working directory.
Which book did you read? I guess you somehow found only strange sets of examples... anyhow.
It's very easy.
- Create an
NSPersistentStoreCoordinator
and tie it to a file name by addPersistentStoreWithType:configuration:URL:options:error:
. (The file doesn't have to exist at this stage. Maybe this part confused you. You need to specify the file name to which the data is later saved.)
- Get an
NSManagedObjectContext
associated to it.
At this stage, the set up of Core Data is ready. Next,
- Create an
NSEntityDescription
for your entity.
- Create the object by
[[NSManagedObject alloc] initWithEntity:entity insertIntoManagedObjectContext:moc]
At this stage, one object is inserted to the context, but is not saved to the disk. When you're done, you do
[moc save:&error];
This will create the SQL file on the disk. You should examine the examples provided by Apple itself, already linked by other posters here. Read also the tutorials provided by Apple itself, like this. They are quite good.
Also, buy Marcus Zarra's Core Data Book, which is very good and helped me a lot.