简体   繁体   English

NSOutlineView列未排序

[英]NSOutlineView column doesn't sort

I can't sort a NSOutlineView in Mac OS X 10.10... 我无法在Mac OS X 10.10中对NSOutlineView进行排序...

    let tableColumn = outlineView.tableColumnWithIdentifier("LocationName")
    println(tableColumn?.description)
    let sorter = NSSortDescriptor(key: "self", ascending: false)
    tableColumn!.sortDescriptorPrototype = sorter
    outlineView.reloadData()

neither with the code above neither setting sorting attributes in Interface Builder. 都不使用上面的代码,也不在Interface Builder中设置排序属性。

Maybe something wrong with "self"? 也许“自我”出了什么问题?

NSOutlineView column contains swift strings, compare: should work, right? NSOutlineView列包含快速字符串,比较:应该可以,对吗? Maybe I simply have to write a comparer? 也许我只需要编写一个比较器?

Setting a table column's sortDescriptorPrototype doesn't cause it to sort. 设置表列的sortDescriptorPrototype不会导致其排序。 It just determines what order that column would be in if the outline view were sorted by that column. 它只是决定什么样的顺序该列是,如果大纲视图是由该列排序。

To sort an outline view, you set the outline view's sortDescriptors property. 要对大纲视图进行排序,请设置大纲视图的sortDescriptors属性。 However, if you're using a data source (rather than bindings) to provide the outline's data, the outline view is just going to tell your data source to sort its data by calling its -outlineView:sortDescriptorsDidChange: method. 但是,如果您使用数据源(而不是绑定)来提供大纲的数据,则大纲视图将通过调用其-outlineView:sortDescriptorsDidChange:方法来告诉数据源对其数据进行排序。 It is then your data source's responsibility to actually sort its data so that subsequent queries by the outline view get the data in sorted order. 然后,数据源有责任对数据进行实际排序,以便大纲视图的后续查询按排序顺序获取数据。 Your data source is also responsible for adjusting the outline view's selection based on how items moved around in the order. 您的数据源还负责根据项目在订单中的移动方式来调整大纲视图的选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM