核心数据与多个sqlite文件 [英] Core Data with mutiple sqlite files

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

问题描述

如何在多个SQLite文件中使用Core Data?

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) )

持久存储协调器支持添加和删除存储。删除时,您要确保内存中没有未保存的更改(很明显),一般来说,删除后,您不会搞砸从删除的存储中提取的任何实体。

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.

但是,请注意,Core Data不支持两端对象在不同存储中的关系。

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

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

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