Using Xcode 7 with a storyboard, I can't figure out how to change the type of one of my table's columns to be a checkbox, instead of a text cell. Everything I try results in all the other columns getting corrupted. Can somebody please point me to instructions on how to do this? I'm targeting the most recent mac version if it matters.
Checkbox in NSTableView
Is this table view cell-based or view-based?
If it's cell-based, the content of a column is a NSCell. Replace the text field cell with a checkbox button cell.
It it's view-based, you just delete the text field in the column and drag a checkbox in instead. However, you have to be very careful because the pieces are labelled confusingly.
— Make sure you do not delete the text field NSCell that's at the first level under the column. It's something used internally by the table view
— The other first level items within the column are alternative cell views. Unless you've added some, I think you'll find only one in a NSTableView columns. (NSOutlineView columns start with two.) That item is the NSTableCellView. Expand it, and you should see the actual text field. Delete this and put a checkbox in its place.
If your table has all the standard IB item names, you should have gone down to Scroll View -> Clip View -> Table View -> Table Column -> Table Cell View -> Table View Cell. Note that the text field called Table View Cell contains a NSCell also
called Table View Cell. Make sure you delete the text field containing that NSCell, not just the NSCell.
(Yes, it's horribly confusing. When in doubt, check the object classes in the utility inspector.)
So I start off with a structure like so:
- Table Column
Table Cell View
- Table View Cell
- Table View Cell
- Number Formatter
- Table View Cell
- Text Cell
- Table View Cell
- Table Column
Table Cell View
- Table View Cell <=- I delete this one
- Table View Cell
- Text Cell
- Table View Cell <=- I delete this one
So I then delete the one that I pointed at, which is the one I think you're telling me to, so it and the one child go away. Now I drag a check cell into that second column, and then suddenly stuff from other columns disappear as well, and I'm left with this:
- Table Column
Text Cell
- Table Column
Check
What did I do wrong?
It's hard to be certain without seeing it in IB, but it looks like you deleted the correct thing. However, when you dragged the checkbox, it looks like, you dragged it as a child of the table view, not of the table column, so now you have 2 columns.
You're dragging the checkbox into an outline view, so it matters not just where you drag it in terms of vertical position (which row the highlight line is below), but where you drag in terms of horizontal position (how much indenting the highlight shows). If you move your mouse left or right while dragging up or down, you should see the start of the highlight line (the little circle) snap to different horizontal positions, indicating which parent item it's going to attach to.
What's confusing is that I believe I've seen IB failing to put the highlight in the right place, according to where the mouse is. You may find it easier to add the checkbox to the original column's cell view before deleting the text field.
If I drag a table view to the controller it defaults to two columns. I then grab a check cell and drag it to the second column and IB adds a little "Table Column" text. I let go, and the same thing as above happens.
As to dragging into the hierarchy directly, xcode will ONLY let me drop it in place of the very last cell. The one that's light blue and says Text Cell.