objective-c – NSTableView如何通过绑定修改NSArrayController的选择?

objective-c – NSTableView如何通过绑定修改NSArrayController的选择?,第1张

概述假设我有以下情况: alt text http://img693.imageshack.us/img693/5818/controllerselection.png 当我在NSTableView中选择不同的行时,它会神奇地更新NSArrayController(PersonController)选择. NSTableView是如何做到这一点的?它是否像这样做: - (void)bind:(NSSt 假设我有以下情况:

alt text http://img693.imageshack.us/img693/5818/controllerselection.png

当我在NStableVIEw中选择不同的行时,它会神奇地更新NSArrayController(PersonController)选择. NStableVIEw是如何做到这一点的?它是否像这样做:

- (voID)bind:(Nsstring *)binding toObject:(ID)observableController withKeyPath:(Nsstring *)keyPath options:(NSDictionary *)options;{ if([observableController isKindOfClass:[NSArrayController class]]){  // got the NSArrayController,which can be used to change selection } else {  // not an NSArrayController,don't try to change selection } //...}

我问,因为我正在实现我自己的可绑定NSControl,我希望它像NStableVIEw一样修改绑定的NSArrayController的选择.

解决方法 在预感中,我覆盖了绑定:toObject:withKeyPath:options:在NStableVIEw和两个NStableColumn对象上并使它们记录它们的绑定.这是输出:

Binding NStableColumn["Last name"].value to key path "arrangedobjects.lastname" of NSArrayController: 0x215fc0Binding NStable.content to key path "arrangedobjects" of NSArrayController: 0x215fc0Binding NStable.selectionIndexes to key path "selectionIndexes" of NSArrayController: 0x215fc0Binding NStable.sortDescriptors to key path "sortDescriptors" of NSArrayController: 0x215fc0Binding NStableColumn["First name"].value to key path "arrangedobjects.firstname" of NSArrayController: 0x215fc0

尽管我所做的唯一绑定是对NStableColumn对象的“值”,但看起来IB正在自动添加其他绑定. NStableVIEw能够修改NSArrayController选项,因为它在IB中自动绑定selectionIndexes.

对于selectionIndexes和sortDescriptors,这在NSTableView Bindings Reference中得到了确认.

总结

以上是内存溢出为你收集整理的objective-c – NSTableView如何通过绑定修改NSArrayController的选择?全部内容,希望文章能够帮你解决objective-c – NSTableView如何通过绑定修改NSArrayController的选择?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1006093.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存