如何从 Xcode 4 中的实体创建用户界面?

发布于 2024-11-04 04:46:56 字数 187 浏览 0 评论 0原文

我已经用核心数据进行了几天的实验,并且在过去的几个小时里尝试找出如何从 xcode 4 中的实体创建 UI。根据我一直在阅读的书籍,您必须选择将核心数据实体拖到界面生成器中的窗口中,但是当我在 xcode 4 中执行此操作时,没有任何反应。 苹果文档没有任何帮助,因为它还没有针对 xcode 4 进行更新。 我确信这是非常明显的事情,但我就是无法弄清楚。

I've been experimenting with core data for a couple of days and have spent the past couple of hours trying to work out how to create a UI from an entity in xcode 4. According to the books I've been reading you have to option drag the core data entity into a window in interface builder but when I do this in xcode 4, nothing happens.
The apple documentation has been no help since it hasn't been updated for xcode 4.
I'm sure it's something really obvious but I just can't figure it out.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灯下孤影 2024-11-11 04:46:56

你的问题对我来说恰逢其时,因为我最近开始学习 Mac / Cocoa 开发并遇到了同样的问题。

查看文档、搜索 Google、尝试所有 Xcode 菜单选项并使用所有可能的鼠标和鼠标后,我能想到的键盘快捷键我得出的结论是,不可能调用向导从 Xcode 4 中的实体生成界面。

这回答了您的问题,但给您带来了与我相同的问题 - 您去哪里现在?

这就是我为让我的应用程序正常工作所做的事情(请注意,Erik Aigner 链接的视频中也对此进行了解释):

  1. 将新的 NSArrayController 拖到您的 NIB 文件上。打开属性检查器并将模式更改为“实体”并将实体名称字段更改为实体的名称(EG 人员)。
  2. 通过将项目拖到窗口上来正常创建界面。
  3. 对于要绑定到实体的每个控件,请执行以下操作:选择控件,打开绑定检查器并将值绑定到数组控制器。控制器键字段应设置为“选择”,模型键路径应绑定到要绑定的实体的字段(EG“名称”)。

显然,这仅适用于非常基本的场景,但应该足以让您开始(如果您正在阅读与我相同的书,那么当您尝试绑定到相关实体时,请准备好在下一章中再次打破一切!)。

我的知识仍然存在一些差距,因为我只学习了 Core Data 2 天(Cocoa / Objective-C 学习了不到一周),所以如果上面的任何信息是错误的,那么 Cocoa 专家应该让我知道了,我会相应地更新我的帖子。

Your question is perfectly timed for me as I recently started learning Mac / Cocoa development and have come across the same problem.

After looking at the documentation, searching Google, trying out all Xcode menu options and playing around with every possible mouse & keyboard shortcut I could think of I have come to the conclusion that it is not possible to invoke the wizard to generate your interface from your entities in Xcode 4.

This answers your question but leaves you with the same issue I had - Where do you go now?

This is what I did to get my application to work (note that this is also explained in the videos linked to by Erik Aigner):

  1. Drag a new NSArrayController onto your NIB file. Open the attributes inspector and change the mode to "Entity" and change the Entity Name field to the name of your entity (E.G. Person).
  2. Create your interface as normal by dragging items onto your window.
  3. For each control you want to bind to your entity do the following: Select the control, open the bindings inspector and bind the value to the array controller. The controller Key field should be set to "selection" and the Model Key Path should be bound to the field of the entity you want to bind to (E.G. "name").

Obviously this only caters for a very basic scenario but should be enough to get you started (If you're reading the same book as me then be prepared for everything to break again in the next chapter when you try binding to related entities!).

There are still a few gaps in my knowledge as i've only been learning Core Data for 2 days (and Cocoa / Objective-C for less than a week) so if any of the information above is wrong then the Cocoa experts should let me know and I will update my post accordingly.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文