开发者

NSArrayController, custom sorting

开发者 https://www.devze.com 2023-01-25 11:35 出处:网络
I have an NSTableView, with each column bound to the appropriate val开发者_运维问答ue in an NSArrayController. One of the columns contains an NSImageCell, displaying an image.

I have an NSTableView, with each column bound to the appropriate val开发者_运维问答ue in an NSArrayController. One of the columns contains an NSImageCell, displaying an image.

I want to sort by this column, but obviously sorting by an image's object value is not what I want. I actually sort by the combination of other fields, but I can't work out how to set this up. When I click on the column header for the field in question, the sort arrows do not appear.

I have NSSortDescriptors applied to the NSArrayController to sort the other columns, but when sorting, it appears that all the NSSortDescriptors have access to is the object value of the table cell.

I need to sort by a comparison method on the object that the object value is a property of. Is this possible? I've already subclassed NSArrayController, and it seems like somewhere in there would be a good bet, but I can't find anything in the documentation that helps.


Ok, so I solved this by just creating the table column in IB and setting the sort key there. Bit of a workaround but it ended up whittling down my code a little, so I can't complain. It does seem strange that you can't set a sort key programatically though. At least, not via any method I can find.

0

精彩评论

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