array problem
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.