Help to make a check box in a list

Hello,

I have a small table consisting of two columns. In the second one, there is an item name. In the first one, I want just a check box to say if the item is selected or not.

My problem is a binding problem, Xcode says

Cannot create BOOL from object ( ) of class __NSArrayI

The records are simply {isSelected:false, name:missing value}. They are added to the list via the controller a the table view. When I don’t put a check box in the column of the table view (in IB), it works, I have:

0 article one
1 article two
0 article three
.

but of course I don’t want text cells filled with 0 and 1, but check boxes.

Any ideas? Thanks.

I might be able to help you.

Can you provide us a dummy copy of the project?

Hello fundidor,

Nice from you, I’m really stuck with this (surely simple) problem. Could you tell me how I can join the empty project?

Thank you,

I’m not sure what the problem is – that binding should work fine. Are you using an array controller? The column with the check boxes should have its value bound to Array Controller.arrangedObjects.isSelected. Have you logged your array to make sure it looks correct – that error looks like maybe something’s wrong with the array?

Ric

Ric, fundidor, don’t get angry after me. please. I dragged a normal check box into the tableview’s cell instead of a checkbox cell. and IB showed me a so nice result that I didn’t notice my mistake.

It works now, thank you.

Is it possible to have my checkbox check/uncheck by clicking anywhere into the row, and not only right into the box? My article name (in the second column) would behave like the title of a checkbox control. Or is it against the Human Interface Guidelines?

Regards,

Yes, you could do that. You would have to use one of the table view delegate methods that’s called when you select a row. Once you have the row number you can use that to get the index in your array and set the value of the isSelected key to what you want.