XCode 4 从 CoreData 中的实体生成类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4061712/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
XCode 4 Generating classes from entities in CoreData
提问by Doz
Im using XCode 4 and working with CoreData. Now, how do I generate classes for entities? I used to do it in XCode 3 by clicking on a diagram entity, going to File->New and choosing NSManagedObject class.
我使用 XCode 4 并使用 CoreData。现在,我如何为实体生成类?我曾经在 XCode 3 中通过单击图实体,转到 File->New 并选择 NSManagedObject 类来完成此操作。
For some reason i cant seem to find it in XCode 4, it's not showing up in the dialog...
出于某种原因,我似乎无法在 XCode 4 中找到它,它没有出现在对话框中......
采纳答案by Adam Eberbach
You'll find in DP5 it is now a menu item. Finally!
您会在 DP5 中发现它现在是一个菜单项。最后!
回答by DariusLau
If you are new to Xcode (like me) some graphics to make it easier to explain. Just make sure that you select the entities that you want before you click on "Create NSManagedObject Subclasss"
如果您是 Xcode 的新手(像我一样),请使用一些图形使其更易于解释。只需确保在单击“创建 NSManagedObject 子类”之前选择了所需的实体
回答by Rayfleck
I got it working by making the entity CLASS the same as the entity NAME, i.e. "Person" instead of "NSManagedObject". I also noticed that I have to invoke File > New File twice (!) The first time, the Managed Object Class template is not available, but the second time it is. No clue why. I'm running XCode 3.2.4.
我通过使实体 CLASS 与实体名称相同来使其工作,即“人”而不是“NSManagedObject”。我还注意到我必须调用 File > New File 两次 (!) 第一次,Managed Object Class 模板不可用,但第二次它可用。不知道为什么。我正在运行 XCode 3.2.4。
回答by jj0b
While editing your xcdatamodel you need to select the entity and make sure the right hand Utilities pane is open. Select the Data Model Inspector (the tab on the right) and you can set the class of your entity to whatever you want.
在编辑 xcdatamodel 时,您需要选择实体并确保右侧的 Utilities 窗格已打开。选择 Data Model Inspector(右侧的选项卡),您可以将实体的类设置为您想要的任何内容。