开发者

How do I sort an NSArrayController by string length using bindings?

I'm trying to use a key-path to sort an NSTableView by the length of each string contained in each row. I'm using an NSArrayController to control my content array, but I'm having trouble finding out where or how to get the array controller to perform this behavior. I know the setting is in开发者_如何学JAVA Interface Builder somewhere; I just can't find it.


In Interface Builder, select your table column and view its Attributes in the Inspector. Enter your key path in the Sort Key field. For example, if you want to sort by the length of string foo, set Sort Key to foo.length (this works because strings have a length method). Then set the Selector field to compare:

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜