• 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
array problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

array problem


  • Subject: array problem
  • From: Sascha Kuehn <email@hidden>
  • Date: Thu, 11 Mar 2004 13:47:53 +0100

hi,

i have a problem with creating an array of arrays
this is my code:

------------------------------------------------------------------------
-
- (void)makeMatrix
{
int i, j;
matrixArray = [[NSMutableArray array] retain];
temp = [[NSMutableArray array] retain];

for(i=0; i<x; i++) // x is an int between 3 and 5
{
for(j=0; j<x; j++) // x is an int between 3 and 5
{
[temp addObject:[NSNumber numberWithInt:0]];
}
[matrixArray addObject:temp];
}
[temp release];
}
------------------------------------------------------------------------
-

what i need is an array of arrays with numbers.
in case of x = 3 like this: {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}}

in case of x = 4 like this: {{0, 0, 0, 0}, {0, 0, 0, 0}, {0, 0, 0, 0},
{0, 0, 0, 0}}

in case of x = 5 like this: {{0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0,
0, 0, 0}, {0, 0, 0, 0, 0}, {0, 0, 0, 0, 0}}

and so on.

but my method don't do that :(

sascha
_______________________________________________
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: array problem
      • From: Dave Rosborough <email@hidden>
  • Prev by Date: Re: Best Background Drawing Strategy
  • Next by Date: problmes with "Graceful Application Termination"
  • Previous by thread: Inter-process privilege verification
  • Next by thread: Re: array problem
  • Index(es):
    • Date
    • Thread