Re: Loop through NSTableView to set NSCell state
Re: Loop through NSTableView to set NSCell state
- Subject: Re: Loop through NSTableView to set NSCell state
- From: j o a r <email@hidden>
- Date: Sun, 14 Apr 2002 16:44:25 +0200
Complying with the MVC pattern you should never need to enumerate over
the cells in the table view - the view is just there do display values,
not provide them. You have "the true" values in your model object.
I would suggest that you set the button state through the table view
delegate methods provided, something like this:
- (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{
if ([[aCell stringValue] isEqualToString:@"someStringValue"]) {
[aCell setNextState]; // If this is the right way to set the state
}
}
Since this method is called once for every displayed cell every time you
reload the table view you will in this way always have the correct cell
state displayed without having to re-display or loop over the cells any
extra times.
j o a r
On Sunday, April 14, 2002, at 04:28 , Onar Vikingstad wrote:
I have been trying to find a way to loop through a NSTableView, row by
row, to check the stringValue of one of the columns up against the
contents of an array I have. If the array-contents match the
stringValue it's just supposed to check the NSButtonCell with
setNextState.
I assume this can be done with using an enumerator, but how? I have
tried fiddling with doing a selectAll on the NSTableView, creating an
selectedRowEnumerator out of that, and then selecting the first row and
start looping through, going down the table row by row. But this feels
like an awfully hard approach, and there must be an easier way!
Hope someone will give me some suggestions or sample code to get me on
the right track here...
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.