views:

14

answers:

1

Hello,

I have a QCView with a boolean input splitter in it. When I try and do [qcview setValue:NO forInputKey:@"showCube"]; it works as expected and the input gets set to NO. However, When I try and do [qcview setValue:YES forInputKey:@"showCube"]; I get EXC_BAD_ACCESS. I have tried using 1, YES, and TRUE and they all give the same error. Whet could be the issue causing this mysterious error?

Thanks

+2  A: 

setValue:forInputKey: expects value to be an object (not a scalar, which you're supplying).

Try

 [qcview setValue:[NSNumber numberWithBool:YES] forInputKey:@"showCube"];

or

 [qcview setValue:kCFBooleanTrue forInputKey:@"showCube"];

(A standalone scalar NO works in this case, since it evaluates to 0, equivalent to nil in Objective-C, which, under some circumstances, can receive messages without exploding. But really you should be using either the NSNumber constructor, or one of the Core Foundation constants.)

smokris
It Worked! Thanks so much for the explanation of why NO worked it makes sense now!
happyCoding25