I am developing a Business directory where I have an array containing business types (Hairdresser, mechanic, etc) and an array containing business sections as letters (Eg. A or B or C or D... or Z, etc).
The data will be shown in a tableview with an A-Z index.
I have set it up as follows but can't think of a way to return the section numbers based on the business section letter.
I want to return the number of objects in the array that have the same business type letter (Eg. A or B or C or D... or Z, etc) in each section.
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 26;
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
NSMutableArray *tempArray = [[NSMutableArray alloc] init];
[tempArray addObject:@"A"];
[tempArray addObject:@"B"];
[tempArray addObject:@"C"];
[tempArray addObject:@"D"];
[tempArray addObject:@"E"];
[tempArray addObject:@"F"];
[tempArray addObject:@"G"];
[tempArray addObject:@"H"];
[tempArray addObject:@"I"];
[tempArray addObject:@"J"];
[tempArray addObject:@"K"];
[tempArray addObject:@"L"];
[tempArray addObject:@"M"];
[tempArray addObject:@"N"];
[tempArray addObject:@"O"];
[tempArray addObject:@"P"];
[tempArray addObject:@"Q"];
[tempArray addObject:@"R"];
[tempArray addObject:@"S"];
[tempArray addObject:@"T"];
[tempArray addObject:@"U"];
[tempArray addObject:@"V"];
[tempArray addObject:@"W"];
[tempArray addObject:@"X"];
[tempArray addObject:@"Y"];
[tempArray addObject:@"Z"];
return tempArray;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// I want to return the number of objects in the array that have the same section name (EG. A or B or C etc)
}