- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
(摘要:绑定(bind)在代码中起作用,但在 IB 中不起作用)
我有一个由 NSWindowController 管理的窗口。窗口左侧是源 View 。右侧是一个表格 View ,显示当前所选源的元素。
我已经在我的窗口 XIB 中设置了一个 NSTreeController。我希望将其内容用于源 View 。它的选择将驱动表格 View 。
我正在尝试使用 NSViewControllers 来分割它。一个 View Controller 将加载包含源 View 的 NIB。另一个 View Controller 将加载 TableView 。
看到我需要访问源 View Controller 中的 NSTreeController,我已将其设置为 View Controller 的representedObject。 (实际上,为了在 View Controller 上调用 awakeFromNib 时完成此设置,我已将representedObject 转换为 IBOutlet)。
当我在代码中连接源 View 时,一切正常:
[outlineView bind:@"content"
toObject:sources
withKeyPath:@"arrangedObjects"
options:nil];
[outlineView bind:@"selectionIndexPaths"
toObject:sources
withKeyPath:@"selectionIndexPaths"
options:nil];
[[outlineView tableColumnWithIdentifier:@"Title"] bind:@"value"
toObject:sources
withKeyPath:@"arrangedObjects.title"
options:nil];
但是,我无法使用 Interface Builder 重现此情况。问题是,这里的“ Controller 键”文本字段呈灰色。因此,我使用“representedObject.arrangedObjects.title”模型 keyPath 将列的“值”绑定(bind)到文件所有者。这没有显示出所需的行为。实际上抛出了一个异常:-[NSProxy doesNotRecognizeSelector:_mutatingNodes]被调用!
如何在IB中使用representedObject?我可以在 IB 中创建一个 Controller 来充当representedObject 的代理吗?我可以在源 View XIB 中设置一个树 Controller ,在 NIB 加载期间将其替换为所表示的对象吗?
最佳答案
我不再使用representedObject。看来这仅适用于模型对象。
我现在使用自定义 socket 传入我的树 Controller 。我继续在代码中设置和拆除绑定(bind)。
关于cocoa - 绑定(bind)到 NSViewController 的representedObject,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1514276/
简而言之:我将 NSTextField 绑定(bind)到文件所有者( View Controller )和 representedObject.firstName 的模型键路径,但编辑文本字段不会改
我已经阅读了一堆 Core Data 示例和 Apple 文档。经过一整天的工作,我已经走到了墙边。 我想要发生的就是在文本字段中输入一些文本,保存文件,再次打开它并查看其中的文本。 我制作了一个非常
当我预先将按钮添加到 NSCollectionViewItem 的 View 时,我可以在检查器中绑定(bind)它的操作: 这没有问题。 现在我想在 View 的 mouseDown: 中以编程方式
我有一个在我的 CollectionView 的每个项目中使用的 View 。从我的 View 中,我有一个指向 CollectionViewItem 的 IBOutlet,并且已将其连接到 Inte
我正在开发一个简单的 OS X Cocoa 应用程序,用户在其中填写表单,应用程序执行一些计算,这些计算会在其他字段中弹出。 我从 Xcode 6.3.2(适用于 Yosemite)上默认的基于文档的
我在尝试将以下代码升级到 Swift 3 时遇到了问题。 我该如何解决这个问题? @IBAction func Quit(_ sender: AnyObject) { NSApp
我是一名优秀的程序员,十分优秀!