I'd suggest you use a C-array, as an NSArray
doesn't support multiple dimensions. You could declare the array you described like this:
NSString *stringArray[16][3];
Setting and accessing any string of this array is quite straight-forward:
stringArray[7][1] = @"Stringstringstring";
NSString *string = stringArray[3][0];
However, you could use an NSArray
(or NSMutableArray
), but that would be a bit less elegant:
NSArray *stringArray = [NSArray arrayWithObjects:
[NSMutableArray array],
[NSMutableArray array],
[NSMutableArray array], nil];
Those three NSMutableArray
s would be the three columns of your two-dimensional array.
Edit
Using an NSArray
, it might be easier to use a loop to fill it:
NSMutableArray *stringArray = [NSMutableArray array];
for (int column = 0; column < 3; column++)
{
NSMutableArray *columnArray = [NSMutableArray array];
for (int row = 0; row < 16; row++)
[columnArray addObject:[NSString stringWithFormat:@"Row %i, column %i", row, column]];
[stringArray addObject:columnArray];
}