[SOLVED] Re: Updating NSTableView after edit
[SOLVED] Re: Updating NSTableView after edit
- Subject: [SOLVED] Re: Updating NSTableView after edit
- From: email@hidden (Kris Rambish)
- Date: Wed, 03 May 2006 14:15:31 +0000
Thanks Stephane! I assumed it was something very, very simple I was missing.
Kris
-------------- Original message ----------------------
From: Stephane Sudre <email@hidden>
>
> Le 3 mai 06, à 08:58, Kris Rambish a écrit :
>
> > 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?
>
> The new value is "anObject".
>
> The value you see in [[aTableColumn dataCell] stringValue] is the one
> of the data cell not of the text editor. Text edition is made in a
> separate widget even if you have the feeling this is done in your text
> field cell.
>
>
_______________________________________________
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