For C I would init an array like this:
NSInteger x[3][10]; That works.
Below I have a one dim array that works. Would like to move all of this to a 2 dim array, How do I init it? So in other words take the code below and make it work with 2 dimensions.
NSMutableArray *SRData;
SRData = [[NSMutableArray alloc] init];
NSMutableDictionary *SRRow;
SRRow = [[NSMutableDictionary alloc] init];
[SRRow setObject:@"Read" forKey:@"Descr"];
[SRRow setObject:@"Read2.png" forKey:@"Img"];
[SRRow setObject:@"Read the codes" forKey:@"Det"];
[SRData addObject:SRRow] ;
[SRRow release];
In Objective-C, you just have to have an array of arrays to get the second dimension. To my knowledge, there is no shorthand, so you’re stuck doing something like the following:
So all you would do is add your other objects (in your case, the
NSMutableDictionarys) to thesecondDimensionarray. Usage would be like:Edit
Full code example:
Now, to get at that “field” you would use code such as the following: