为什么我在 Xcode 中看不到托管对象类文件模板?
我在 Xcode 中创建了一个 .xcdatamodel 托管对象模型文件。我在“组和”中选择了该文件文件。然后我转到“文件”>“新...>>在 iPhone 模板/Cocoa Touch 类模板中,我没有看到“托管对象类”文件模板。
有谁知道可能出了什么问题?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
我通常还需要选择要为其生成类文件的实体。
I usually need to also select the entities for which I want to generate the class files.
在 Xcode 4 中,选择 xcdatamodeld 中的实体,然后选择 Editor Menu >创建 NSManagedObject 子类
In Xcode 4, select the entity in the xcdatamodeld, then choose Editor Menu > Create NSManagedObject Subclass
如果您想子类化 NSManagedObject 那么我强烈建议您看看 mogenerator (github)。它会自动为您生成子类,并在您更新模型时使它们保持同步。它还具有机器类与人类类的概念,以便您可以添加方便的方法等,而无需每次更新模型时都踩踏您的代码。
If you are wanting to subclass NSManagedObject then I would highly recommend talking a look at mogenerator (github). It will autogenerate the subclasses for you AND keep them in sync as you update your model. It also has the concept of machine classes vs. human classes so that you can add convenience methods, etc. without your code being stepped on each time you update your model.
我以前也见过这个问题。对我来说,解决方案是单击非数据模型文件(在“组和文件”中),然后单击返回版本化数据模型文件(及其中的实体),然后尝试“文件”->“文件”。新文件。或者,重新启动 xcode,选择数据模型文件(及其中的实体),然后尝试 File ->新文件也对我有用。
I've seen this problem before as well. Solution for me was to click on a non-data model file (in Groups & Files) and then click back on the versioned data model file (and entity within it) and then try File -> New File. Alternatively, restarting xcode, selecting the data model file (and entity within it) and then trying File -> New File also worked for me.
单击左上角的“Simulator 3.1.2 | debug”。将其更改为“IPHONE Device 3.1.2 (BASE SDK)...瞧。(SAMS iphone in 24hrs?大量拼写错误和不完整的程序!)
Click On the top left where it says "Simulator 3.1.2 | debug". Change it to "IPHONE Device 3.1.2 (BASE SDK)... voila. (SAMS iphone in 24hrs?? lots of typos and incomplete procedures!)
托管对象类文件模板可以在 XCode 4 的新文件创建选项的“核心数据”部分中看到。
下面的屏幕截图描述了它。
谢谢,
亲开发者。
Managed Object Class file template can be seen under "Core Data" section of new file creation option of XCode 4.
The following screenshot depicts it.
Thanks,
prodeveloper.