What is the correct way to send static (read-only) data to Core Data persistent storage?

I want to send read-only static data for use in my Core Data model. The problem is that there are obviously different persistent storage types, and I don’t know if the format of these types should be opaque or I would have to create them manually.

Right now I have a plist and it is very small (only 30 entries).

Should I just write the code to import plist into my data store when the application was first installed, or is there some way I can send the initial version of the data store file manually?

(I use sqlite persistent storage by default.)

+3
source share
3 answers

I would not try to create it manually, but you must definitely import and save the final SQLite SQL Server file to send with your application.

I plan to write a small mac utility (using the same data model) to create a SQLite Core Data file for my iPhone application (import from a web server). Then I will add the file that the utility saved to my iPhone application project.

+3
source

To add a little answer to my question, I noticed that the sample recipe sample application comes with the default sqlite repository by default:

// If the expected store doesn't exist, copy the default store.
if (![fileManager fileExistsAtPath:storePath]) {
    NSString *defaultStorePath = [[NSBundle mainBundle] pathForResource:@"Recipes" ofType:@"sqlite"];
    if (defaultStorePath) {
        [fileManager copyItemAtPath:defaultStorePath toPath:storePath error:NULL];
    }
}

, , plist! (TemperatureData.plist) ....

+1

, OSX , iOS. , ​​ ( OSX).

OSX , IOS SDK: -)

0

Source: https://habr.com/ru/post/1727573/


All Articles