Re: Slow scrolling after NSPopup implementation
Re: Slow scrolling after NSPopup implementation
- Subject: Re: Slow scrolling after NSPopup implementation
- From: Steven Hamilton <email@hidden>
- Date: Fri, 15 May 2009 20:41:22 +1000
On 15/05/2009, at 8:12 PM, Kyle Sluder wrote:
On Fri, May 15, 2009 at 5:56 AM, Steven Hamilton <email@hidden>
wrote:
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
{
if ([[tableColumn identifier] isEqualToString:@"transfer"])
{
self.selectedTransferIndex =
[[self.formattedTransactions
objectAtIndex:row] objectForKey:@"transfer"];
return nil;
Why are you setting this property inside of
-tableView:objectValueForTableColumn: ? This generates a ton of KVO
activity because this method is called very frequently. As the docs
say, it needs to be fast.
It looks like you're relying on this method being called first for the
"transfer" column to set your property to change your
NSArrayController's contents. Bad idea. Not only is it slow, but
it's logically incorrect and prone to breakage. What happens if
NSTableView decides to instead ask for the columns out-of-order?
NSTableView tries to minimize its redrawing work, so I would expect
this issue to arise at some point when only part of your table view
needs drawing.
Hmm, clearly I'm doing it all wrong. I assumed (from past problems)
that the delegate method can't return a value to an popup in a
tableView and that you use the opportunity of the method call to set
the selectedIndex. I've now changed the code to the standard;
- (id)tableView:(NSTableView *)tableView objectValueForTableColumn:
(NSTableColumn *)tableColumn row:(int)row
{
return ([[self.formattedTransactions objectAtIndex:row] objectForKey:
[tableColumn identifier]]);
}
but the entire column of popups display the same object even though
the formattedTransactions array contains the correct index numbers.
_______________________________________________
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