I'm a newbie in Objective c and Cocoa, and I have some troubles with using NSTableView (Cell based NSTableView). I have two questions
First I want to automatically to update some data in the tableview once the user hits enter after modifying a cell. I know how to update the data because I use a NSDictionnary and an arraycontroller to fill the tableView, but I don't know or rather I don't understand how to fire an action once the user modify a cell in a certain column.
To populate the tableview i use this code:
//Code for inserting data into my tableview when the user enter the "i" key
-(void)keyDown:(NSEvent *)event
{
static int i = 1; // used as a counter
NSString * str = [NSString stringWithFormat:@"%i", i];
NSMutableString *str2 = [NSMutableString string];
[str2 appendString:@"Task "];
[str2 appendString:str];
if([event keyCode] == 0x22)
{
dict = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:false], @"check",str,@"numero",str2,@"designation",@"1",@"length",²"13/07/17",@"debpr",@"12/07/17",@"finpr",@"11/07/17",@"debpr1",@"12/07/17",@"finpr1",@"0",@"mgt", nil];
checkState = [NSMutableDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:false],[NSNumber numberWithInteger:i], nil];
[_arrayController addObject:dict];
[check setTag:i];
}
nbrTasks = i;
i++;
}
it works, I can modify my tableview cells but I cannot fire an action when editing is done. I tried to insert some action using the Cell View in the interface builder but it didn't work, nothing changes when I change the value in my TableView. Can someone explain it, using code examples? Because I'm really new to programming in Objective C and Cocoa and I don't know how to do it.
Secondly, I want to know how can I fire an action when selecting some rows, let's say I want to change a label when a specific row is selected. How do I do it?
NSTableViewDelegate
for selection change notifications. – Willeke