Xcode 和 Interface Builder 中的绑定 Minefield

发布于 2024-08-13 00:15:44 字数 861 浏览 9 评论 0原文

好吧,在完成 Cocoa Dev Central 的“构建核心数据应用程序”教程之后,我开始了尝试构建我自己的应用程序,使用教程中的代码和 .nib 文件作为参考,以确保所有内容正确组合在一起。总的来说,我处理得很好,但我似乎遇到了障碍。

我正在构建一个带有两个 NSTextView 框的表单,就像教程中一样,但链接到同一实体中的不同属性。当我在记录之间切换时,所有其他控件都可以正常工作并保存/刷新它们的值(减去一些日期框的愚蠢,其中第二个框不想保存其值)。我已经根据教程中的 .nib 检查了所有绑定设置和 NSArrayController,以了解哪里可能出现问题;这导致取消第一个文本框的挂钩,然后使用相同的设置重新连接它,它突然神奇地工作了。然而,第二个盒子不想表现出来,并且坚持破坏程序(调试器出现,列出所有类型的变量和内存地址以及坦率地说完全超出我理解范围的东西)。

目前,有问题的盒子配置如下:

Class: NSTextView
Value: Bound to `history`
    Controller Key: selection
    Model Key Path: `description`
    Checked: Allows Editing Multiple Values Selection
    Checked: Conditionally Sets Editable
    Checked: Raises For Not Applicable Keys

了解这里发生了什么吗?

All right, after having worked through Cocoa Dev Central's "Build a Core Data Application" tutorial I started experimenting with building my own application, using the code and .nib file from the tutorial as a reference to make sure that things are put together properly. Overall I've been managing pretty well with it, however I seem to have hit a snag.

I'm building a form with two NSTextView boxes, like in the tutorial, however linked to different attributes within the same entity. All the other controls work properly and save/refresh their values when I go between records (minus some date box silliness, where the second box doesn't want to save its values). I have checked all of the bindings settings and the NSArrayController against the .nib from the tutorial to see where things could be off; that led to unhooking the first text box and then reconnecting it with the same settings and it suddenly magically working. The second box doesn't want to behave, however, and persists in breaking the program (the debugger shows up, listing all manner of variables and memory addresses and stuff that's frankly quite beyond my comprehension).

Currently, the offending box is configured as follows:

Class: NSTextView
Value: Bound to `history`
    Controller Key: selection
    Model Key Path: `description`
    Checked: Allows Editing Multiple Values Selection
    Checked: Conditionally Sets Editable
    Checked: Raises For Not Applicable Keys

Any insight into what's going on here?

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

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

发布评论

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

评论(1

初吻给了烟 2024-08-20 00:15:44

好吧,明白了。更改了 description 中的属性名称,它开始运行;似乎这个名字在编译时触发了一些东西,导致最初的错误检查错过了。

All right, got it figured out. Changed the attribute name from description and it started behaving; seems the name was triggering something when it compiled that the initial bug check missed.

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