NSTableView update triggered from a thread
NSTableView update triggered from a thread
- Subject: NSTableView update triggered from a thread
- From: Eyal Redler <email@hidden>
- Date: Sat, 30 Jun 2007 10:11:10 +0300
Hi,
My application has thread that does a periodical scan of available
resources. The scan results are packed inside and array and passed to
the owner object in the main thread (communication is done via
distributed objects). The "owner" copies this array and then presents
the results in an NSTableView.
When not doing anything, the table view updates very nicely and
everything looks great but if I'm resizing the window I'm sometimes
getting exceptions.
What I'm seeing is that the table view is calling the data source
methods with rowIndexes that lie outside of the current array size.
It seems that even though I'm calling "reloadData" after setting the
array, the table view still keeps the old number of rows somewhere
for the duration of the resize. I'm also getting similar problems
when scrolling through the table view.
I tried adding "noteNumberOfRowsChanged" but didn't see any
improvement. Note that the array size can grow and *shrink* very
rapidly so it is not just adding items to the list while interacting
with the user.
The simplest solution would be to check rowIndex when
"tableView:objectValueForTableColumn:row:" but I'm worried that I
might be missing a more "proper" solution. Maybe I should wait with
the updated data for a more appropriate time (letting the user see
the old data while scrolling and resizing)?
Any help or advice with this would be greatly appreciated.
Eyal Redler
------------------------------------------------------------------------
------------------------
"If Uri Geller bends spoons with divine powers, then he's doing it
the hard way."
--James Randi
www.eyalredler.com
_______________________________________________
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