开发者

Core Data with multiple sqlite files

Ho开发者_运维知识库w may I use Core Data with multiple SQLite files?

Each file contains the same structures but the data is retrieved from different locations.

I want to be able to switch between these sqlite files at runtime based on application settings.


Sure; just point the persistent store coordinator (NSPersistentStoreCoordinator) at the different databases, as needed.

Persistent store coordinators support addition and removal of stores. On removal, you want to make sure that there are no unsaved changes in memory (obviously) and, in general, that you will not be messing with any entities fetched from the removed store after removal.

Be careful, though, as Core Data does not support relationships where the objects at either end are in different stores.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜