Sorting of table column by string length not working as intended when done in IB via cocoa - binding

Posted by Miraaj on Stack Overflow See other posts from Stack Overflow or by Miraaj
Published on 2010-06-13T13:56:14Z Indexed on 2010/06/13 14:02 UTC
Read the original article Hit count: 287

Hi all,

I made a sample application displaying list of employees with their salaries over NSTableView using NSArrayController.

Basic functionality is working as intended. Also sorting is working fine when Selector - compare or caseInsensitiveCompare is assigned in attribute pane for table column- employeeName.

Problem occurs when I try to sort it by string length by setting selector in IB as - length, for the table column - employeeName. It does sorting by string length but does it inappropriately.

It is doing sorting on alternate clicks ie. on first click it sorts the content in table in descending order by length. Then on second click it does not arrange contents in ascending order by length but sets arrow on top as in ascending. Then on third click it arranges contents in ascending order by length but sets arrow on top of table column as in descending and so on...

Can anyone suggest if I am wrong somewhere?

Thanks,

Miraaj

© Stack Overflow or respective owner

Related posts about sorting

Related posts about cocoa-bindings