• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag
 

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Updating NSTableView after edit
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Updating NSTableView after edit


  • Subject: Re: Updating NSTableView after edit
  • From: Stephane Sudre <email@hidden>
  • Date: Wed, 3 May 2006 12:38:24 +0200


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
References: 
 >Updating NSTableView after edit (From: email@hidden (Kris Rambish))

  • Prev by Date: Re: Efficiently getting characters
  • Next by Date: Re: NSTableView question
  • Previous by thread: Updating NSTableView after edit
  • Next by thread: Linker Trouble
  • Index(es):
    • Date
    • Thread