Updating NSTableView after edit
Updating NSTableView after edit
- Subject: Updating NSTableView after edit
- From: email@hidden (Kris Rambish)
- Date: Wed, 03 May 2006 06:58:01 +0000
Hi all,
I have been setting up my NSTableView and have hit a problem I couldn't find a good answer to. What I have done is setup a NSTabView that has 6 columns. Three of them are NSPopUpButtonCell's and I have no problem collecting the users changes and adding them to my data source. However I cannot get the simple NSTextField columns to work. This is what I have:
//m_clientList is a NSMutableArray -- my data source
- (id)tableView:(NSTableView *)tableView
objectValueForTableColumn:(NSTableColumn *)tableColumn
row:(int)row
{
//If we are reading a popup button row
if (([[tableColumn identifier] isEqualToString:@"iterationType"]) ||
([[tableColumn identifier] isEqualToString:@"enumerationType"]) ||
([[tableColumn identifier] isEqualToString:@"status"]))
{
NSMutableDictionary *theRecord = [NSMutableDictionary dictionaryWithDictionary:[m_clientList objectAtIndex:row]];
NSString *theValue = [NSString stringWithString:[theRecord objectForKey:[tableColumn identifier]]];
return [NSNumber numberWithInt:[[tableColumn dataCell] indexOfItemWithTitle:theValue]];
}
return [[m_clientList objectAtIndex:row] objectForKey:[tableColumn identifier]];
}
- (void)tableView:(NSTableView *)aTableView
setObjectValue:anObject
forTableColumn:(NSTableColumn *)aTableColumn
row:(int)rowIndex
{
if (([[aTableColumn identifier] isEqualToString:@"iterationType"]) ||
([[aTableColumn identifier] isEqualToString:@"enumerationType"]) ||
([[aTableColumn identifier] isEqualToString:@"status"]))
{
NSMutableDictionary *theRecord = [NSMutableDictionary dictionaryWithDictionary:[m_clientList objectAtIndex:rowIndex]];
[theRecord setObject:[[[aTableColumn dataCell] itemAtIndex:[anObject intValue]] title] forKey:[aTableColumn identifier]];
[m_clientList replaceObjectAtIndex:rowIndex withObject:theRecord];
return;
}
//If we are reading a NSTextField row
if (([[aTableColumn identifier] isEqualToString:@"folderPath"]) ||
([[aTableColumn identifier] isEqualToString:@"numberOfIterations"]))
{
NSMutableDictionary *theRecord = [NSMutableDictionary dictionaryWithDictionary:[m_clientList objectAtIndex:rowIndex]];
[theRecord setObject:[[aTableColumn dataCell] stringValue] forKey:[aTableColumn identifier]]; //This is always the previous text entry not the new one
[m_clientList replaceObjectAtIndex:rowIndex withObject:theRecord];
return;
}
[m_clientList replaceObjectAtIndex:rowIndex withObject:anObject];
return;
}
My question is why is [[aTableColumn dataCell] stringValue] the old string value and not the new one just entered?
Thanks,
Kris
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden