Hunter Mitchell
Hunter Mitchell

Reputation: 7293

Adding rows in a NSTableView?

I have a tableView and two buttons. One to add a row, and one to remove a row(selected).

  1. How would I add a row of textbox cells?
  2. Also, how would i remove the selected row?
  3. Would it be possible for the user to select a row, not just individual cells?

Upvotes: 2

Views: 3500

Answers (1)

Anoop Vaidya
Anoop Vaidya

Reputation: 46533

If you are looking for Mac OSX :

You can use two ways, in both the cases you deal with the model not the view : ArrayController using Binding and Conventional Programming.

1 How would I add a row of textbox cells?

//in the IBAction of add button
[yourModelArray addObject:newObject];
[yourTableView reloadData];

2 Also, how would i remove the selected row?

//in the IBAction of remove button
[yourModelArray removeObjectAtIndex:[yourTableView selectedRow];
[yourTableView reloadData];

3 Would it be possible for the user to select a row, not just individual cells?

NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:1];
[yourTableview selectRowIndexes:indexSet byExtendingSelection:NO];
//If you want to select multiple rows, use YES.

Upvotes: 6

Related Questions