• 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
Simple Key Value Coding Question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.


  • Follow-Ups:
    • Re: Simple Key Value Coding Question
      • From: Chris Hanson <email@hidden>
  • Prev by Date: Re: Array controllers again: still in dark...
  • Next by Date: in-program database solution
  • Previous by thread: Customizing WebKit form widgets?
  • Next by thread: Re: Simple Key Value Coding Question
  • Index(es):
    • Date
    • Thread