具有多个sqlite文件的核心数据 [英] Core Data with multiple sqlite files

查看:79
本文介绍了具有多个sqlite文件的核心数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将Core Data与多个SQLite文件一起使用?

How may I use Core Data with multiple SQLite files?

每个文件包含相同的结构,但数据是从不同的位置检索的。

我希望能够在运行时根据应用程序设置在这些sqlite文件之间进行切换。

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.

推荐答案

可以;只需指向持久性商店协调员(NSPersistentStoreCoordinator )(根据需要)。

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.

这篇关于具有多个sqlite文件的核心数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆