0
votes

i have NSTableView bound to an NSArrayController. in my model i have a BOOL field. i'm trying to bind that value to the column. it displays correctly (1 where value is YES and 0 where value is NO), but it's readonly. =( when i'm trying to edit a value i can't submit it -- when i press enter nothing happens, setter is never invoked. column is editable.

i can successfully bind it with IB -- i just bind it as usual and all works. but i can't do the same programmatically =(

that's how column is created and added:

NSTableColumn *column = [[[NSTableColumn alloc] initWithIdentifier:@"ok"] autorelease];
[column setEditable:YES];
[[column headerCell] setStringValue:@"OK"];
[column bind:@"value" toObject:self.arrC withKeyPath:@"arrangedObjects.ok" options:nil];
[table addTableColumn:column];

i have a problem only with BOOL values, if i bind the same column to some other field (just changing keyPath) all works fine.

4
by the way, the same problem with NSTextCell -- i can't edit it.. - Vyacheslav Karpukhin

4 Answers

1
votes

it's readonly =(. when i'm trying to edit a value i can't submit it -- when i press enter nothing happens, setter is never invoked. column is editable.

And then, in your code snippet:

[column setEditable:NO];

Your column is not editable. That's why editing doesn't work. Change NO to YES.

By the way: Is there a reason you're displaying this value as text and not a checkbox?

0
votes

You need to bind the table column, not the cell.

0
votes

What is bound to arrC which I am assuming is your array controller?

Is arrC bound to an array? What's are the objects in the array bound to the controller? Coredata entities? NSMutableDictionaries?

0
votes

You need a value transformer, specifically NSNegateBooleanTransformerName. Google for Apple's "Value Transformer Programming Guide"