If you want to do this using arrays, you can intialize your sections
array, then add a rows array as follows:
NSMutableArray *sections = [[NSMutableArray alloc] init];
NSMutableArray *rows = [[NSMutableArray alloc] init];
//Add row objects here
//Add your rows array to the sections array
[sections addObject:rows];
If you want to add this rows object at a certain index, use the following:
//Insert your rows array at index i
[sections insertObject:rows atIndex:i];
You can then modify this rows array by retrieving the array:
//Retrieve pointer to rows array at index i
NSMutableArray *rows = [sections objectAtIndex:i]
//modify rows array here
You could always create your own class called Section
, which has an NSMutableArray
member called rows
; then you store your rows inside this array, and store the Section
objects in an array:
@interface Section : NSObject {
NSMutableArray *rows;
}
Then you simply create Section
items, and you can create methods inside your class to add/remove row items. Then you package all the Sections
items up inside another array:
Section *aSection = [[Section alloc] init];
//add any rows to your Section instance here
NSMutableArray *sections = [[NSMutableArray alloc] init];
[sections addObject:aSection];
This becomes more useful if you want to add more properties for each Section
instance.