Simple Key Value Coding Question
Simple Key Value Coding Question
- Subject: Simple Key Value Coding Question
- From: Keith Renz <email@hidden>
- Date: Sat, 24 Apr 2004 15:32:16 -0400
I've got what I think is a simple Key Value Coding question.
I have an NSMatrix of checkboxes, bidEntryChoicesMatrix, in a
preferences window. I store the cell states in a temporary array of
NSNumbers, tempBidEntryChoices, with the following action method where
sender is the matrix:
- (IBAction)setBidEntryChoices:(id)sender
{
[self setTempBidEntryChoices:[sender valueForKeyPath:@"cells.state"]];
}
[sender valueForKeyPath:@"cells.state"] returns an array of NSNumbers
courtesy of KVC. What I can't figure out how to do is the reverse, i.e.
set the matrix's cell states from an array of NSNumbers using KVC. The
best I can come up with is something like this:
NSArray *cellsArray = [bidEntryChoicesMatrix cells];
int i;
for (i = 0; i < [cellsArray count]; i++)
[[cellsArray objectAtIndex:i] setState:[[tempBidEntryChoices
objectAtIndex:i] intValue]];
This seems like a waste when there's probably a more elegant way.
Thanks,
Keith
_______________________________________________
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.