0
votes

I currently have a core data schema with four entities, several with many-to-many relationships with each other. I'd like to pre-populate the sqlite database for my core data store, but I'm uncertain which way is best. I'm currently considering creating a property list (to be converted to JSON), that I will then parse with a JSON parser object which will read in the properties and store them into core data. Alternatively, I could use XML.

So, which approach is easier to accomplish, and is best practice?

1

1 Answers

0
votes

All your formats are fine (JSON, plist, XML). I would avoid converting between these before putting the data into core data, though - this would clearly be redundant.

For JSON - you can use the JSON parser you mentioned.

For XML - you could use NSParser, but it is a bit more involved, with delegate methods etc. but still feasible.

For plist - you can just convert these into one big array or dictionary in one line, just like with the JSON parsers, so no need to go from there to JSON. Plist is of course the Apple native format (a kind of XML), but perhaps JSON is better readable for humans.