Managing coredata/sqlite database lifecycle in iOS project
I'm writing an ios app which browses(read only) a sqllite db. As the pro开发者_StackOverflow中文版ject evolves, the the db entities will change (add/modify attributes). Presumably I should get xcode to rebuild the "Managed Object class" when this happens, is that all I need to do? What about the database? How do I transition the data to the new data model?
From what I know, there is no way for you to control the structure of a Core Data database. Because CoreData gives you a lot of goodies - the visual object design and mapping - it needs to control the database's structure and content. That means that loading your own SQLite database and having CoreData manipulate it is impossible. You need to have core data load, manage, store all the data that is there. Core Data is ideal if it manages local data for the app, not when it needs to load a new database it did not create. For those instances, use either the native C layer of SQLite or a library like FMDB.
精彩评论