views:

49

answers:

2

hi,

I have around 100 plists in my application and I am planning to move that to a sqlite database. Is there a way to insert all these 100 plists into the database during the 'build' and make it available in the application after installation ?

+1  A: 

If you are able to do it with a shell script, you can add that script to the build phase in xcode. You can handle plists via command line with PlistBuddy, and surely there is some command line tool for sqlite, so it should be doable.

garph0
can you get any examples on this ?
thndrkiss
I am not an expert in shell scripting. Here http://macscripter.net/viewtopic.php?id=18380 there are some examples of plistbuddy usage (it's applescript, but it launches shell commands to manipulate plists).When you obtain the values you need you can just echo some INSERT query to a .sql file and then feed the command file to sqlite executable to create the database.
garph0
+1  A: 

The best answer is to create a command line Core Data application that loads up those plist files and saves out a sqlite file. You can then take that sqlite file and include it in your iPhone application.

The sqlite that Core Data generates should be considered a black box and therefore should only be edited by Core Data. It is far easier to write the Core Data command line app then it is to try and reverse engineer the core data store plus you are future proof whereas designing your own sqlite file outside of Core Data will break at some point.

Marcus S. Zarra