0

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.

Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131

4 Answers4

1

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?

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • originally it was YES.. don't know how it ended up with NO. anyway -- doesn't help. problem is not there. i can access editor after double click, but can't submit value. – Vyacheslav Karpukhin Jun 26 '09 at 03:41
0

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

Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
  • sorry, i didn't describe it well enough. actually, i'm binding column. the problem is only with BOOL values -- string and integer values are working correct.. – Vyacheslav Karpukhin Jun 25 '09 at 02:37
  • In that case, please edit your question to include a screenshot of the Bindings inspector with the column selected. – Peter Hosey Jun 25 '09 at 04:44
  • the problem is, that i can make it work with IB without any problems. but i can't make it work if i create column and add it to the table at the runtime process -- it works with other fields, but doesn't work with BOOL fields. – Vyacheslav Karpukhin Jun 25 '09 at 15:13
  • In that case, please edit your question to include the code you're using to create, add, and bind the table column. – Peter Hosey Jun 25 '09 at 21:22
0

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?

Jeff Hellman
  • 2,117
  • 18
  • 17
0

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

Elise van Looij
  • 4,162
  • 3
  • 29
  • 52