• 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
Re: NSMutableArray & NSMatrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMutableArray & NSMatrix


  • Subject: Re: NSMutableArray & NSMatrix
  • From: Jyrki Wahlstedt <email@hidden>
  • Date: Wed, 11 Jun 2003 13:34:47 +0300

Hi,
if you look at the documentation of NSMatrix you'll see that selectedRow returns an index, an integer that is not an object you could store in an array. So you should enumerate the cells of the row in some meaningful way and use the results as objects to put in the array. What are the cells anyway?
I myself have done something similar in my SquashCounter program, in which I allow the user to modify the action keys. There the modifiers are put in a matrix and I calculate the modifiers to use based on the states of checkboxes.
The code to set the modifier value:
int row, column;
unsigned int modifier;

row = [sender selectedRow];
column = [sender selectedColumn];
modifier = [[[displayedValues objectForKey:modifierKey] objectAtIndex:row] unsignedIntValue];
if ([[sender selectedCell] state] == NSOnState)
modifier |= [[[displayedValues objectForKey:modifierConsts] objectAtIndex:column] unsignedIntValue];
else
modifier &= ~[[[displayedValues objectForKey:modifierConsts] objectAtIndex:column] unsignedIntValue];
[[displayedValues objectForKey:modifierKey] replaceObjectAtIndex:row withObject:[NSNumber numberWithUnsignedInt:modifier]];

and to set the matrix based on the modifiers (this code is just an excerpt from a larger one):
for (i = 0; i < rows; i++) {
modifier = [[sm objectAtIndex:i] unsignedIntValue];
for (j = 0; j < columns; j++) {
[[modifierMatrix cellAtRow:i column:j] setState:(modifier & [[mc objectAtIndex:j] unsignedIntValue])];
}


On keskiviikko, kesd 11, 2003, at 12:43 Europe/Helsinki, Peter Karlsson wrote:

Dear list!

I want to store the state of a NSMatrix in a NSMutableArray but I can't get it to work. I also want to set the state of the NSMatrix from my NSMutableArray.

Here is my code to store the NSMatrix into the NSMutableArray (does not work)

[myMutableArray replaceObjectAtIndex: 0 withObject:[myNSMatrix selectedRow]];

Any code example?

Peter

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. http://join.msn.com/?page=features/virus
_______________________________________________
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.


!
! Jyrki Wahlstedt
! Sammonkatu 10 B 13 mob. +358-40-502 0164
! FI-87100 Kajaani
!
! Our life is no dream; but it ought to become one and perhaps will.
_______________________________________________
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.

References: 
 >NSMutableArray & NSMatrix (From: "Peter Karlsson" <email@hidden>)

  • Prev by Date: Re: G4 vs G3
  • Next by Date: Disable spell checking menu in NSTextField
  • Previous by thread: Re: NSMutableArray & NSMatrix
  • Next by thread: G4 vs G3
  • Index(es):
    • Date
    • Thread