My iPhone app currently uses Core Data to save Growth Entries created by the user. I’m trying to add a .sqlite file to the app that stores average growth data so that I can use Core Plot to show the user how their growth compares to the average.
- My app is working perfectly for storing and retrieving the user’s data.
- I have written a utility app that creates a .sqlite file containing the average data
- I have copied the average growth data class files, the data model, and the .sqlite file into my main app.
Note: The average data does not need to be writable.
After much searching of Stack Overflow and countless Googles, I have come to the conclusion that what I want to do is implement two PersistentStoreCoordinators: one for the user entered data (readwrite), and one for the average data (readonly). Is that the best course?
If so, I don’t know where to start. Currently, my Core Data Stack methods are in my AppDelegate.m (where Xcode put them). It feels like I should move them into a better place if I’m going to add much to them, but I don’t know where that better place might be. And besides that, I don’t know where I should start trying to add the new persistent store.
Thanks for the help!
Edit for clarification:
If my suggestion of creating two PersistentStores is the right route, how do I do that? If it’s not the best route, what should I do?
I have solved my problem. Here is what I did:
NOTE: you do not need to create the database before generating the data. That will be done for you automatically when you create a new entity.
The only downside for me is that I haven’t found a way to prevent overwriting the data in the “second” database. But I’m still looking for a solution to that.