gpt4 book ai didi

ios - 从 Sqlite 迁移到 CoreData

转载 作者:搜寻专家 更新时间:2023-10-30 23:00:53 24 4
gpt4 key购买 nike

到目前为止,我有一个应用程序在其中使用 Sqlite 数据库。我想升级应用程序并提供核心数据而不是 Sqlite。我需要将现有的 sqlite 数据库数据迁移到新的核心数据数据库。

我知道我需要从 sqlite 数据库读取数据并在 NSManagedObjectContext 准备好使用后将其写回核心数据数据库的手动方式。

我正在寻找一些自动化的方式。有什么方法可以摆脱手动方式并将现有数据从 sqlite 数据库保存到新的核心数据数据库?

最佳答案

来自 Core Data's FAQ :

How do I use my existing SQLite database with Core Data?

You do not, unless you import your existing SQLite database into a Core Data store. Although Core Data supports SQLite as one of its persistent store types, the database format is private. You cannot create a SQLite database using the native SQLite API and use it directly with Core Data. If you have an existing SQLite database, you need to import it into a Core Data store. In addition, do not manipulate an existing Core Data-created SQLite store using the native SQLite API.

您必须自己将其自动化。

关于ios - 从 Sqlite 迁移到 CoreData,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32945146/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com