PDA

View Full Version : NSTableView Multiple textfield cells in one cell, driving me nuts.




detz
Jan 29, 2009, 05:13 PM
I've been trying to get this to work all day and I just can't get it. I have two items showing in the cell but I can't figure out how to change the text once it's there.

CustomCell (http://pastebin.com/m182cc2fb)

Would I have to do something in this method?

- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex{
NSLog(@"%@ - %d",aTableColumn, rowIndex);
if ([[aTableColumn identifier] isEqualToString:@"Title"]){
//something to change the values?
}

return [title objectAtIndex:rowIndex];
}

The picture shows what I'm trying to do, I need to change both of those values under Title.



kainjow
Jan 29, 2009, 11:03 PM
There are two ways. One would be to use your current method and return some object that stores both values (such as a dictionary) and then retrieve that dictionary in your custom cell via the objectValue method (or override the setObjectValue: method and update your text fields there), or write accessor methods to those text fields in the cell and set them appropriately in tableView:willDisplayCell:forTableColumn:row: