0

I've checked a lot of sites and answers and I can't find any solutions specific to my problem.

I don't need to change the schema for my Core data model, all I need is to modify (add some) content to the current backing SQL Database.

Any direction on this will be welcome. Thanks.

PS: I tried Apple docs and they were about as useful to me as sunshine on Mecury.

Also go easy please, I'm a beginner.

Thanks.

UPDATE;

To shed more light on my issue, my app works as thus. I have preloaded static information on the app that can't be changed by the user, each day has new content. Every month, I push an update with entirely new content specific to that month. However, when my app entered production, upon the update I pushed for this month, my users were complaining that they couldn't access the month's data. This led to me spamming them with Push notifications to have them delete the app and do a fresh install to access the new data.

How can I fix this issue? my schema stays the same, only the data changes.

Josh
  • 225
  • 2
  • 14

2 Answers2

0

Don't work on the SQLite-Database directly. Change all your Data through NSManagedObjectContext! To find a good strategy look up examples from Batch-Importing.

Update: You could actually have two PersistentStores (one with just static data (readonly) and the other one with user-generated data). You could interchange the readonly which you prefilled with a commandline util and downloaded from a server. You cannot have direct relationships between those two store though. I would say that it depends on the amount of data in this prefilled store wether you should go this way or just use a plist and reference some string constants in your user data store. Try to do it with a plist as this is the simpler approach.

Karl
  • 1,233
  • 8
  • 16
  • Okay, here's how I update my SQL DB. I use a mac command line app I wrote that parses my JSON into the SQL DB which I then reference from my App. – Josh Jun 21 '13 at 09:55
  • Well, you can also use Core Data in command line apps, just make sure to share the same model. I'm not quite sure where you're going... – Karl Jun 21 '13 at 10:00
0

If I understand correctly you want to pre-fill a Core Data database ?

If you don't care about pre-existing data on existing app, you can make an iPhone or Mac app with the same model, and let it generate the database, like explain here (Any way to pre populate core data?) it's also the way recommended in a really great book if you want to learn more about Core Data (http://pragprog.com/book/mzcd2/core-data).

Do not ever make SQL request directly, Core Data work in his own magic way.

Community
  • 1
  • 1
Boris Charpentier
  • 3,515
  • 25
  • 28