On 15/05/2009, at 8:12 PM, Kyle Sluder wrote:

On Fri, May 15, 2009 at 5:56 AM, Steven Hamilton <o...@scorch.net> 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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to