Re: NSTableView: tableView:objectValueForTableColumn:row called more than necessary when scrolling
Re: NSTableView: tableView:objectValueForTableColumn:row called more than necessary when scrolling
- Subject: Re: NSTableView: tableView:objectValueForTableColumn:row called more than necessary when scrolling
- From: John Terranova <email@hidden>
- Date: Wed, 16 Jan 2008 15:07:25 -0800
Ben,
In my app I am drawing pages of pdf files in my tables. Drawing a pdf
page (into an NSImage, in my case) can take a long time, depending on
the complexity of the page. A file with complicated pages will
display one cell at a time with a pause after each cell. This is
unusable.
My solution is to cache the NSImage of each pdf page and just retrieve
that image, rather than drawing the pdf page each time the cell
draws. I use NSOperation to draw the pages in a separate thread and
my table dataSource/delegate will have the table redraw just the cell
of a newly available pdf page image. Before an image is ready, the
table just draws an empty image frame.
Of course, you don't need to complicate things with NSOperation and
delayed drawing. You can just cache the table data the first time the
cell draws.
The docs for tableView:objectValueForTableColumn:row: say that this
method "must be efficient" and I make mine efficient by caching my
table data.
Good luck.
john
On Jan 16, 2008, at 2:07 PM, Ben Chen wrote:
Hi everyone,
I just found that when scrolling a NSTableView inside a NSScrollView
one row at a time, each time the tableview will not only ask the data
source for the new row's value but also ask for the last row's. So if
you scroll the table all the way donw, eventually it makes twice calls
as the number of rows in the table.
I been programming a app that performance of the table view is vital,
so I really want the table view call the data source as few as
possible. Does anyone know a solution?
Thanks,
Ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden