title: NSTableView with Checkbox Cell
body: <p>After adding a <code>NSTableView</code> to my xib on Xcode 4 I set it to have 4 columns. The 1st column is a simple column that will contain the name of an item. The other 3 are checkboxes. I dragged a <code>Check Box Cell</code> from the object library to the tableview.</p>
  
  <p>I populate the table and the checkboxes get created and shown, however if I click on the nothing happens, I can't check or uncheck them. Furthermore, I don't even know how to do it by code.</p>
  
  <p>How can I make this work: be able to check or uncheck the checkboxes and get their states from code.</p>
  
  <p>I already saw <a href="https://stackoverflow.com/questions/4313490/nsbuttoncell-as-checkbox-in-a-nstableview-dont-get-selected">this question</a> and it didn't really answer my question.</p>
  
  <p>Here is some of the code to take care of table, as requested:</p>
  
  <pre><code>- (int)numberOfRowsInTableView:(NSTableView *)tableView
  {
      return (int)[myArray count];
  }
  
  - (id)tableView:(NSTableView *)tableView objectValueForTableColumn:(NSTableColumn *)tableColumn row:(int)row
  {
      if([[tableColumn identifier] isEqualToString:@"col1"])
      {
         return[NSNumber numberWithInt:NSOffState];
      }    
  
      return [myArray objectAtIndex:row];
  }
  
  - (void)tableView:(NSTableView *)tableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
  {
      NSLog(@"%d", [anObject boolValue]);
      if([[tableColumn identifier] isEqualToString:@"col1"])
      {
          NSLog(@"click col1");
      }        
      if([[tableColumn identifier] isEqualToString:@"col2"])
      {
          NSLog(@"click col2");
      }        
  
  }
  </code></pre>
  
  <p>I just added more code. How do I set it to check/uncheck?</p>