I am trying to learn how to code a UITableView and is having some problems with the programming of the section.
I have declared 3 arrays with strings and 1 array with the 3 arrays.
firstSection = [NSArray arrayWithObjects:@"Red", @"Blue", nil];
secondSection = [NSArray arrayWithObjects:@"Orange", @"Green", @"Purple", nil];
thirdSection = [NSArray arrayWithObject:@"Yellow"];
array = [[NSMutableArray alloc] initWithObjects:firstSection, secondSection, thirdSection, nil];
To shows the headers
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
NSString * title;
title = [NSString stringWithFormat:@"%@" , [array objectAtIndex:section]];
return title;
}
which shows the array itself as the headers

therefore is it possible to actually show the name of the sections using the names of the arrays such as firstSection and secondSection?
In your case, it’s better to store your arrays in an
NSDictionary. For example, if you declare and synthesize anNSDictionaryvariable calledtableContentsand anNSArraycalledtitleOfSections, you can do something like this:Then in the table view controller methods:
Then to access the contents of each array in your
cellForRowAtIndexPathmethod: