views:

138

answers:

2

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?

A: 

as i found out, binding several controllers to one view is not possible. possible solution is to create a "proxy" object, which has a several properties, and then bind this object with a keypath like

prop1.someRealProp prop2.someRealPropOfSecondObject

Vyacheslav Karpukhin
A: 

Could you post some details on the "proxy" object you mentioned? How does that work? Thanks.

Andrew

related questions