NSTableView with columns bound to different NSArrayControllers

Posted by Vyacheslav Karpukhin on Stack Overflow See other posts from Stack Overflow or by Vyacheslav Karpukhin
Published on 2009-08-30T14:08:37Z Indexed on 2010/06/11 6:02 UTC
Read the original article Hit count: 266

Filed under:

i have NSTableView and two columns in it:

    NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"custId"] autorelease];
[column bind:@"value" toObject:arrC2 withKeyPath:@"arrangedObjects.custId" options:nil];
[table addTableColumn:column];

column = [[[NSTableColumn alloc] initWithIdentifier:@"totalGrams"] autorelease];
[column bind:@"value" toObject:valuationArrC withKeyPath:@"arrangedObjects.totalGrams_double" options:nil];
[table addTableColumn:column];

as you can see, columns bound to different NSArrayControllers. first column shows correct values, but second just shows "(" symbol. but if i swap columns like this:

    NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"totalGrams"] autorelease];
[column bind:@"value" toObject:valuationArrC withKeyPath:@"arrangedObjects.totalGrams_double" options:nil];
[table addTableColumn:column];
column = [[[NSTableColumn alloc] initWithIdentifier:@"custId"] autorelease];
[column bind:@"value" toObject:arrC2 withKeyPath:@"arrangedObjects.custId" options:nil];
[table addTableColumn:column];

then i see values of first column (which was second in the first example) and again "(" in the second column. i don't understand that behaviour. how can i bound two array controllers to one table?

© Stack Overflow or respective owner

Related posts about cocoa-bindings