Maintaining selection while actively updating table contents
Maintaining selection while actively updating table contents
- Subject: Maintaining selection while actively updating table contents
- From: "John C. Daub" <email@hidden>
- Date: Fri, 09 Jan 2004 13:05:51 -0600
Hello.
In my app I spin off a thread to perform a lengthy operation. The data
collected by this operation is displayed to the user in an NSTableView. What
happens is the thread does work, collects data, stores the data in my data
model. The table's data source reads from my data model to know what to
display. I have an NSTimer installed which fires every 1.0 seconds and does
a reloadData on the table. This way the user gets a more or less live feed
of the data the thread is collecting.
The data can be sorted by selecting various columns in the table, and I've
been able to add a mechanism to preserve the selection when the data is
sorted. That is, I want to ensure that the item(s) selected before the
(re)sort remain selected after the (re)sort (i.e. selecting the item, not
the row displaying the item). What I do is determine the selected rows,
obtain the items displayed in those selected rows and save references to
those items in a collection, do the sort, then look up the collected items
in the newly sorted data, find their index, and then select that row in the
table. Works fine.
The trouble I'm having is trying to maintain the selection while the table
is going through its live updates. I tried updating my timer callback so
instead of just calling reloadData it would use the same routines I have to
save/restore the selection and then save, reloadData, restore. But that
didn't work.
I've searched the archives and see that others have dealt with issues of
live table updating, but no specific mentions were made about maintaining
the selection (unless I overlooked a post/thread).
I'm looking for suggestions on how I can maintain the selected items while
the table is being updated.
Thanx. :-)
--
John C. Daub }:-)>=
<
mailto:email@hidden> <
http://www.hsoi.com/>
"Virtue does not come from money, but rather from virtue
comes money, and all other things good to man." - Socrates
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.