1

I have a tableview bound with array controller.There are two columns in table view,one is string and another one is BOOL.I am getting string values in tableview.For displaying BOOL values in NSButtonCell,I am facing problem.The button cell was selected,where the values are "NO" and unselected for where the values are"YES". I have given value transformer as "NSNegateBoolean" to the BOOL column in binding.I know,this problem is due to I had given "NSNegateBoolean".But there is no option like "NSBoolean" to get exact values.If any one knows, plz guide me to do.This app is in cocoa,not in iPhone.

Thanks in Advance.

Preethi
  • 371
  • 2
  • 6
  • 20

2 Answers2

0

Do you mean that you couldn't bind BOOL value to NSArray directly?

Could you try NSNumber NSCFBoolean?

@(YES) or @(NO).

or

BOOL boolValue = YES;
@(boolValue)

such as

NSDictionary *row1 = @{@"title":@"row1",@"value":@(YES)};
NSDictionary *row2 = @{@"title":@"row2",@"value":@(NO)};
NSArray *tableContentArray = @[row1,row2];

tableContentArray is the one which bind to your ArrayController.

YuDenzel
  • 413
  • 3
  • 16
0

All that NSNegateBoolean transformer does is to invert your bound values before reflecting them in the interface and of course is optional. If you do not need to negate the values just do not use a transformer. So, remove NSNegateBoolean and you should be good to go.

Alladinian
  • 34,483
  • 6
  • 89
  • 91
  • Then what transformer should i use? If i didn't use transformer,all the check boxes are coming as unselected. – Preethi Feb 22 '13 at 10:45
  • You should not use a transformer. The reason you might get unexpected results is that bindings expect your properties to be objects (not primitives like `int`s, `float`s etc). So if you got `BOOL`s from your database try to wrap them into `NSNumber` before you try to establish any bindings. I hope that this makes sense... – Alladinian Feb 22 '13 at 10:58