PDA

View Full Version : Sorting in NSTableView




satyam90
Sep 8, 2009, 02:18 AM
I am using Cocoa framework with Obj C.
I have a NSTableView whose columns are bind to NSArrayController's arranged object's properties. Table view allows sorting of columns manually by user.
Its working fine.

Now, my NSArrayController's contents will be updated every 5 minutes. During update, old objects of array controller will be deleted and added again. So, automatically my table view contents changes accordingly. But its not maintaining the sorting order that it previously has.

Can some body suggest me how to update the table view without loosing the sorting order?



mongrol
Sep 8, 2009, 05:28 PM
"losing" not "loosing"

[NSTableView reloadData];

satyam90
Sep 9, 2009, 02:10 AM
thanks for correcting me.

We don't have to call [NSTableView reloadData], because its already bind to NSArrayController and what ever data is in array controller, it will be shown in tableview.
my question is how to maintain the sorting....

mongrol
Sep 9, 2009, 05:18 PM
Can you explain the behaviour a bit more? Are user's manually setting the sort order to their preference, then when the data changes it's reverting back to a default sort? Or are items being added to teh end (or beginning) of the table.

Generally you set bind the tableview's Sort binding to a NSSortDescripter somewhere.