ios - 核心数据类的重新声明无效

标签 ios swift core-data nsmanagedobject

我在一个名为“RoleName”的实体上使用 CoreData。

问题是:我在我的模型中单击“创建 NSManagedObject 子类”,因此它会自动为我的实体创建类。

但是,在类的声明中,我得到了这个错误:

Invalid redeclaration of "RoleName"

即使我没有任何其他同名的类(class)。

最佳答案

这是因为 Xcode 会自行处理所有这些。我觉得这有点麻烦,因为自动生成的类没有我的所有属性。

所以请按照以下步骤来获得它以前的样子:

  • 删除您已经为核心数据创建的类。
  • 将 class.Module 设置为当前产品模块 enter image description here

  • 将 Class.codegen 设置为手动/无

enter image description here

  • 现在选择您的实体并创建 NSmanagedobject 子类 enter image description here

  • 一切就绪

关于ios - 核心数据类的重新声明无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40410169/

相关文章:

ios - 为什么我不能从另一个类中获取关联的对象?

ios - Collection View 树表示

swift - 逗号分隔的条件和使用双符号的条件有什么区别

swift - 如何在 swift 中为枚举添加更多案例

ios - 希望快速将用户输入发送到网络服务器并加载结果

ios - Firebase 通知 Swift 3 SecondViewController

ios - 如何使用 scrollViewWillEndDragging :withVelocity:targetContentOffset to ensure only stops scrolling at two possible positions?

ios - NSPredicate 检查 swift 中对象类的种类

ios - 核心数据添加关系作为唯一约束 - iOS

ios - 核心数据 : when to 'free' unused NSManagedObjects with [ refreshObject:obj mergeChanges:NO]?