Re: NSTableView updating single cells
Re: NSTableView updating single cells
- Subject: Re: NSTableView updating single cells
- From: "Louis C. Sacha" <email@hidden>
- Date: Wed, 5 May 2004 14:59:11 -0700
Hello...
I don't know if this will work (I can't test this at the moment), but
you could try "dirtying" just the rows or cells that need to be
updated...
For example, if you wanted to update a particular row:
NSRect updateRect = [yourTableView rectOfRow:rowToUpdate];
if (updateRect != NSZeroRect) {[yourTableView
setNeedsDisplayInRect:updateRect];}
Or for a particular cell,
NSRect updateRect = [yourTableView
frameOfCellAtColumn:columnofCell row:rowOfCell];
if (updateRect != NSZeroRect) {[yourTableView
setNeedsDisplayInRect:updateRect];}
That way, hopefully the NSTableView would redraw only the needed
rects, and only reload the data for those specific cells. It is also
possible that the "dirty" rects will be combined into one large rect,
which would mean a more cells being redrawn, but in most cases it
would still help, especially if all of the updated cells are close to
each other. Of course, it's also possible that it won't cause the
cells to be updated at all, or it might end up triggering a full
reload anyway, since this is just a theory based on the documentation.
Hope that helps,
Louis
Nicolas Berloquin <email@hidden>
mmm, maybe I wasn't very clear in my explaination (my english is not
too good).
Lets say all rows are showing.
But only certain cells need updating (data is different, has
changed, and the cell should be redrawn with the new data). If the
data hasn't changed, I'd prefere NOT to have the cells refetch the
data and draw it (this seems what takes all the cpu time when ALL
the cells are redrawn every second).
As for the datasource, I'm not doing anything fancy, I have an array
witn one entry per row, and inside the array, a dictionary with a
key per column identifier, so you can't really be much faster here.
What I'm saying is that if only a little percentage of the cells
have new data in them, calling reloadData and having the whole table
draw is slow.
But maybe this comes from the data inside the cells ?
Here's what I have:
- 8 texfields with simple text in them
- 4 NSImageCells with 16*16 icons (that show on/off states)
- 1 NSImageCell with a bigger image that gets scaled to the size of the cell.
And there can be 50-100 rows.
_______________________________________________
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.