绑定到 NSTreeController SelectionIndexPaths

发布于 2024-09-13 19:33:22 字数 521 浏览 7 评论 0原文

我想通过执行以下操作以编程方式绑定到 NSTreeController 的选择索引路径(以便我可以获取一个选择字符串并在文本视图中显示)

[activePDFView绑定:@“名称” toObject:treeController withKeyPath:@"selectionIndexPaths.nodeName" 选项:选项];

树控制器绑定到一个 NSMutableArray,其中包含具有“nodeName”属性的对象。 NSMutableArray 内的对象对于属性“nodeName”来说是符合 KVC 的,因为我已经实现了正确的访问器。

当我编译时,我收到以下消息

'[<__NSArray0 0x1001698d0>> addObserver:forKeyPath:选项:上下文:] 不支持。关键路径:nodeName'

我不太确定,但我的绑定正确吗?

谢谢。

I want to bind to a NSTreeController's selectionIndexPaths programatically by doing the following (so that I can get a string a selection and display in a text view)

[activePDFView bind:@"name"
toObject:treeController
withKeyPath:@"selectionIndexPaths.nodeName"
options:options];

The tree controller is bound to a NSMutableArray that contains objects with the "nodeName" property. The object inside the NSMutableArray is KVC compliant for the property "nodeName" since I've implemented the proper accessors.

When I compile, I get the following message

'[<__NSArray0 0x1001698d0>
addObserver:forKeyPath:options:context:]
is not supported. Key path: nodeName'

I am not quite sure but is my binding correct?

Thanks.

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

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

发布评论

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

评论(1

早茶月光 2024-09-20 19:33:22

看起来您想要绑定的不是 selectionIndexPaths,而是 selection 绑定。 selectionIndexPaths 绑定将返回一个 NSIndexPath 对象数组,通常仅在将大纲/浏览器视图的选择绑定到树控制器时使用。 selection 实际上返回一个代理对象,它可以表示单个或多个选择,并将任何 KVC 请求传递到底层选定的对象。它在 NSObjectController 中定义,它是 NSTreeController 的超类。在你的情况下,你会想要:

[activePDFView bind:@"name" toObject:treeController withKeyPath:@"selection.nodeName" options:options];

It looks like what you want to bind to is not selectionIndexPaths, but instead the selection binding. The selectionIndexPaths binding will return an array of NSIndexPath objects, which is typically only used when binding an outline/browser view's selection to the tree controller. selection actually returns a proxy object which can represent either a single or multiple selection, and passes through any KVC requests to the underlying selected object(s). It's defined in NSObjectController, which is a superclass of NSTreeController. In your case, you would want:

[activePDFView bind:@"name" toObject:treeController withKeyPath:@"selection.nodeName" options:options];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文