0

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.

M P
  • 352
  • 3
  • 14

1 Answers1

0

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.

atomkirk
  • 3,701
  • 27
  • 30
  • Thanks for the response but how would i know that this row is in edit mode and i should not refresh it. I mean is there any method like shouldRefreshRowAtIndexPath:? I know i can have row index using shouldEditTableColumn method. – M P Jun 06 '14 at 11:40
  • Thanks for clarification. So you mean instead of reloadData i should use "reloadDataForRowIndexes:(NSIndexSet *)rowIndexes columnIndexes:(NSIndexSet *)columnIndexes" this method in case of edit mode. – M P Jun 06 '14 at 13:15
  • exactly, that way you won't be disturbing the currently editing cell, losing the text the user has entered. – atomkirk Jun 06 '14 at 14:26
  • Yes this will work i guess but my table data source might have new row s in data set after 5 seconds so i think index will be changed automatically when sorting is enabled and this will mess up indexes of rows. – M P Jun 07 '14 at 01:56