问题描述
使用 Xcode 8.1 版.
Using Version 8.1 of Xcode.
在 .xcdatamodeld 文件中创建一个名为MapRegionObject"的实体.
Create an entity named "MapRegionObject" in .xcdatamodeld file.
使用自动代码生成器,点击导航栏上的Editor -> create NSManagedOject Subclass...
Using auto code generator, click Editor on the navigation bar -> create NSManagedOject Subclass...
有两个文件:MapRegionObject+CoreDataClass.swift 和 MapRegionObject+CoreDataProperties
Got two files : MapRegionObject+CoreDataClass.swift and MapRegionObject+CoreDataProperties
屏幕截图中显示的两个文件中的错误:MapRegionObject+CoreDataClass.swift
Errors in two files showing in the screenshot:MapRegionObject+CoreDataClass.swift
MapRegionObject+CoreDataProperties
MapRegionObject+CoreDataProperties
请帮我修复这个错误,非常感谢!
Please help me fix this bugs, thank you so much!
推荐答案
在 Xcode 8.1 中,在使用自动代码生成器之前,您必须选择数据模型中的实体:
In Xcode 8.1, before using the auto code generator, you must select the entity in your data model:
然后转到数据模型检查器选项卡:
Then go to the Data Model Inspector tab:
在Codegen"下选择Manual/Node"
Under "Codegen" select "Manual/Node"
之后,您可以创建一个 NSManagedObject
子类而不会出错.
After that you could create a NSManagedObject
subclass without errors.
或者,如果您已经使用了类定义",您可以进入现有的 .xcdatamodeld 文件并将所有当前实体设置为 Codegen 下的手动/无".确保保存您的项目(File -> Save),删除您现有的派生数据,清理项目,然后构建.为我解决了它,而无需重新制作我的整个模型.
Alternatively, if you have already used 'Class Definition', you can go into your existing .xcdatamodeld file and set all current entities to 'Manual/None' under Codegen. Make sure to save your project (File -> Save), delete your existing Derived Data, clean the project, and then build. Resolved it for me without having to re-make my whole model.
这篇关于自动代码中的无效重新声明生成 NSManagedObject 子类 Swift 3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!