gpt4 book ai didi

cocoa - NSOutlineView 和选择索引路径

转载 作者:行者123 更新时间:2023-12-03 16:45:45 28 4
gpt4 key购买 nike

我想获取/设置NSOutlineView的选择索引路径。我该怎么做?

没有明显的方法来获取/设置选择索引路径。

如果您尝试绑定(bind)选择索引路径,并且没有将它们绑定(bind)到树 Controller ,则它根本不起作用。

大纲 View 似乎并没有真正理解选择索引路径的概念。我该怎么办?

最佳答案

使用以下代码保存选择状态而不进行绑定(bind):

NSIndexSet* theSelectedRows = [self.tableView selectedRowIndexes];
NSMutableArray* selectedItems = [[NSMutableArray alloc] init];

[theSelectedRows enumerateIndexesUsingBlock:^(NSUInteger i, BOOL *stop) {
[selectedItems addObject:[self.tableView itemAtRow:i]];
// or add some other identifier specific to your data model
}];

要在 View 的选择更改时收到通知,请为 NSOutlineView 设置委托(delegate)并在该委托(delegate)中实现:

- (void)outlineViewSelectionDidChange: (NSNotification *)notification

关于cocoa - NSOutlineView 和选择索引路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30042643/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com