objective-cmacoscocoanstableviewnstablecolumn

NSTableView column editing with auto refresh of table


I have a NSTable that is being refreshed in each 5 seconds with new data. Now i have to add a new column to edit that user can edit. At the first time it is working edit column becomes un editable when table is being refreshed after 5 second.

So far example i have started editing the column and writing long text but just after 5 second table got refreshed and all text was gone.

How to handle this situation? One solution could be to stop refresh of table when it is in edit mode. Please suggest.

Regards, MP.


Solution

  • Use the methods that reload data for only certain rows/columns and refresh all the cells except the one you're editing.

    So you would use tableView:shouldEditTableColumn:row: to detect when a cell begins editing. Then, you would keep track of the this column and this row as the currently editing row and column.

    Then, you would use reloadDataForRowIndexes:columnIndexes: to reload all row/column indexes except for the one that corresponds to the currently editing cell.