开发者

Core Data with multiple sqlite files

开发者 https://www.devze.com 2023-03-12 23:05 出处:网络
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.

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

精彩评论

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