Populating sqlite db created by CoreData
I have a sqlite DB created by my CoreData model automatically开发者_JAVA技巧, but my app will not give the user the ability to write data into it, instead I wanted to pre-populate it with all the data the program needs. My problem is that the sqlite DB created by CoreData has unknow tables and fields that where not present in my model. Is there anyway I can populate the DB created automatically with sqlite and only then use CoreData to read it?
The sqlite store created by Core Data should not be edited directly. Use Core Data to populate it.
How did you create the original sqlite db you're trying to use? If you created it with Core Data then you should be able to copy it into your app as long as the model is the same.
You should prepopulate it using core data. This might be useful www.pragprog.com
The best way is to ship a prepopulated sqllite database. If you have to update the database or want to perform the initial load, I can highly recommend this entry: http://cocoawithlove.com/2009/11/writing-parser-using-nsscanner-csv.html
精彩评论