Я обычно использую NSArrays в NSArray для этого.
Вот так я бы создал массив источника данных:
NSArray *section0 = [NSArray arrayWithObjects:@"Section 0 Row 0", @"Section 0 Row 1", nil];
NSArray *section1 = [NSArray arrayWithObjects:@"Section 1 Row 0", @"Section 1 Row 1", @"Section 1 Row 2", nil];
self.tableViewData = [NSArray arrayWithObjects:section0, section1, nil];
и некоторые методы UITableView, чтобы вы поняли:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [self.tableViewData count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [[self.tableViewData objectAtIndex:section] count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MyObject *object = [[self.tableViewData objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];
// Do something
}
А для заголовков (и индексов) разделов я создаю отдельные NSArrays.