database - 重命名 CoreData 类,同时允许 App 更新

标签 database xcode cocoa-touch core-data

我在开始编写 iPhone 应用程序时犯了一个错误,没有为我的类名添加前缀,因此有冲突(一个名为 Category 的 CoreData 类)。在最近更新 Xcode 之前,该项目构建良好,直到现在我才意识到错误。

是否可以在更新后保持工作系统的同时重命名 CoreData 类? 如果我向 Datamodel 添加一个新版本并重命名该类,App 会更新,但似乎旧表已被删除并创建了一个新的(空)表。显然,随后的所有链接都已断开。我想在进行更改的同时维护数据。

在 Java EE 中,如果我没记错的话,您可以否决表名,因此我可以坚持使用旧的类名来命名表。 CoreData有这种可能性吗?

提前致谢!我必须找到一种方法来更新数据库,而不会破坏所有应用程序。

最佳答案

实际上,Apple 已经很好地记录了它:

If you rename an entity or property, you can set the renaming identifier in the destination model to the name of the corresponding property or entity in the source model. You typically set the renaming identifier using the Xcode Data Modeling tool, (for either an NSEntityDescription or an NSPropertyDescription object). In Xcode, the renaming identifier is in the User Info pane of the Detail Pane, below the version hash modifier (see The Browser View in Xcode Tools for Core Data). (Mac OS X Developer Library )

但实际上对我来说,似乎只更改类名并让模型的其余部分保持不变。

关于database - 重命名 CoreData 类,同时允许 App 更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6422913/

相关文章:

ios - Plist 加载中出现奇怪的情况

xcode - iPhone-iPad的其他应用名称

objective-c - 使用图案颜色的描边路径来模拟画笔纹理

database - 如何在磁盘上布局 B-Tree 数据?

Cassandra 在写入/更新之前读取

ios - 配置火力地堡

ios - 动画入门

php - 选择从字段 3 到字段 4 的唯一行

sql - has_table 键的日期期间

iphone - 设计 : Passing on class instances or using singletons?