1
votes

I have a JSON file. The size is around 20MB.

Project 1. So, I created a project and imported data from that JSON file to Core Data. Core Data creates the following sqlite files, entireDataList.sqlite, entireDataList.sqlite-shm and entireDataList.sqlite-wal. It took 10 minutes to copy entire content from JSON to core data and its one time file creation.

Now in Project2. I copied all the three files in MainBundle.I have to create .xcdatamodeld as if I directly copy it from Project1, it does not find the .momd file.

    NSURL *storeURL = [[NSBundle mainBundle] URLForResource:@"entireDataList" withExtension:@"sqlite"];
    store =[[NSPersistentStoreCoordinator alloc] initWithManagedObjectModel:[self managedModel]];
    NSError *error;
[store addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:nil error:&error];

So, is storeURL from NSBundle mainBundle is a reliable approach, where entireDataList.sqlite, entireDataList.sqlite-shm and entireDataList.sqlite-wal files are stored?

Generally they are into documents directory.

1
So the intention is that this is seed data to start the app off but it can then be edited by the user and the edits saved? - Wain
Yes, its like no user entry..I c where you are pointing this too.. i.e I will be able to read but not write? - NNikN

1 Answers

0
votes

Generally speaking you should copy the files from the bundle into the documents folder on first launch, then open them from there. This approach will then allow you to edit the contents of the files and save the updates.