Sorting in NSTableView

Discussion in 'Mac Programming' started by satyam90, Sep 8, 2009.

  1. satyam90 macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #1
    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?
     
  2. mongrol macrumors regular

    Joined:
    Jul 16, 2007
    #2
    "losing" not "loosing"

    [NSTableView reloadData];
     
  3. satyam90 thread starter macrumors regular

    satyam90

    Joined:
    Jul 30, 2007
    Location:
    Bangalore, India
    #3
    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....
     
  4. mongrol macrumors regular

    Joined:
    Jul 16, 2007
    #4
    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.
     

Share This Page