If you want to be able the start with a complete database, the fastest way would be to create a persistent store file that already has all the data in it and add it to your apps bundle. When the app launches for the first time, you could copy the the file from the bundle to the documents directory before setting up your NSPersistentStoreCoordinator
and start using it:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *storeURL = [[self applicationDocumentsDirectory] URLByAppendingPathComponent:@"database.sqlite"];
if(![fileManager fileExistsAtPath:[storeURL path]]) {
NSURL *template = [NSURL fileURLWithPath:[NSBundle pathForResource:@"start-database" ofType:@"sqlite" inDirectory:nil]];
[fileManager copyItemAtURL: toURL:storeUrl error:nil];
}
After that continue as normal with the setup of your NSPersistentStoreCoordinator
.
You could pre-populate the database by running the app yourself, adding all the items, saving the context, and then quitting the app. After that copy the created sqlite database file and add to the resources of your app.