将值绑定到数组的第 n 个对象
我有一个 NSView
和一个 NSArrayController
,我想将该视图内的一些值绑定到数组控制器的arrangedObjects 数组中的对象。我该怎么做?我考虑过创建一个像“currentObject”这样的属性并将所有内容绑定到它。但这对我来说似乎很丑陋..
(我对所有对象只有一个视图,但用户应该能够单击下一个和后退。)
I have an NSView
and an NSArrayController
and I'd like to bind some values inside that view to an object in the array controller's arrangedObjects array. How would I do this? I thought about creating a property like "currentObject" and bind everything to that. But this seems ugly to me..
(I only have one view for all the objects but the user should be able to click on next and backward.)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你真正想实现什么目标?通常,“详细视图”绑定到数组控制器的选择,而不是给定索引处的对象。如果您始终连接到同一个对象,只需使用 NSObjectController,将其内容对象设置为所需的对象,然后将您的视图绑定到它。
What are you really trying to accomplish? Normally a "detail view" is bound to the array controller's selection, not an object at a given index. If you'll always be wired to the same object, just use an NSObjectController, set its content object to the desired one and bind your view to it instead.