开发者

NSOutlineView selection binding error

I got the next situation: NSOutlineView <-> NSTreeController <-> MyClass

I bind the NSTreeController to an array of objects in MyClass, now I want to get the selected item from the NSOutlineView. For this i declare a NSMutableIndexSet and bind it to the NSTreeController via the "Selection Index Paths" binding how is bo开发者_运维知识库und to the NSOutlineView.

I log the description of the index every time that a row is selected and this is the output: " 1 indexes [3, 1]" what looks good.

Now, how can I actually get the value of this index? If i try:

[selection firstIndex]

, for example, i got a '-[NSCFArray firstIndex]: unrecognized selector sent to instance'.

Thanks


The solution:

NSIndexPath *index = [(NSArray *)selection objectAtIndex:0]

Then i can read the 'index' in this way:

for (int i = 0; i < [index length]; i++){
...
[index indexAtPosition:i]
...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜