Re: Table view data source methods order?
Re: Table view data source methods order?
- Subject: Re: Table view data source methods order?
- From: Chase Meadors <email@hidden>
- Date: Mon, 3 Aug 2009 17:16:00 -0500
I think this isn't working either. Let me post the relevant code and
see if you notice anything off the bat.
- (NSCell *)tableView:(NSTableView *)sender dataCellForTableColumn:
(NSTableColumn *)tableColumn row:(NSInteger)row {
//cut: judge column and row...
NSPopUpButtonCell *cell = [[NSPopUpButtonCell alloc] initTextCell:@""
pullsDown:YES];
[cell removeAllItems];
[cell addItemsWithTitles:[self listForColumn:tableColumn row:row]];
//[cell setObjectValue:[NSNumber numberWithInt:15]]; (adding in this
line appears to have no effect)
return cell;
//cut...
}
- (id)tableView:(NSTableView *)sender objectValueForTableColumn:
(NSTableColumn *)tableColumn row:(NSInteger)row {
//cut: judge row and column...
//find the index of a string in the list of strings for this
particular row (which should be the popup cell's menu for this row)
int index = [[self listForColumn:tableColumn row:row] indexOfObject:
[model objectForEntry:currentEntry handler:row]];
NSLog(@"row %d --- %d", row, index); //reports correct
return [NSNumber numberWithInt:index];
//cut...
}
Adding the line in the first method that should set it's object value
doesn't appear to do anything. Index 0 is still selected.
On Aug 3, 2009, at 4:05 PM, Quincey Morris wrote:
On Aug 3, 2009, at 13:24, Chase Meadors wrote:
Maybe I'm missing what you mean here, but if I do that, then what
should I do in the objectValueFor... method?
On Aug 3, 2009, at 2:13 PM, Quincey Morris wrote:
Yes, but according to that message you *didn't* set the correct
selection index in #1. I really think that's what you need to do.
The objectValue... method should return the index of the selected
menu item, because that's what the value is for that column.
I'm going to change my earlier answer on the other part.
When you don't implement tableView:datCellForTableColumn:row:, the
table view obviously has to set the object value of the (shared)
cell it knows about for each row, and it would do that by calling
the objectValue... data source method *after* it has found the cell
to use. My *expectation* would be that it'd do the same thing for
the result of dataCell..., but the documentation doesn't say
anything about that one way or the other.
So I would still try having dataCell... retrieve the selected menu
item index (possibly by calling objectValue... directly) and see if
setting it solves the problem. If so, then answer is apparently that
dataCell... is required to set up the desired object value. If not,
this is a false trail.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden