I implemented a table filled with basic data, and now I'm trying to index it using sections, displaying a side alphabet (in the format of "Contacts as").
In the code below, if I use a commented line, I only have letters for existing sections. But I want the whole alphabet, and so I changed the returned array:
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
indexArray = [NSArray arrayWithObjects: @"{search}", @"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J",@"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", @"#", nil];
return indexArray;
}
All letters are displayed in the side pointer. But now I have to implement a method that returns the index of the selected section, and here I have some problems:
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index
{
NSString *correspondingLetter = [indexArray objectAtIndex:index];
NSUInteger correspondingIndex = [[fetchedResultsController sections] indexOfObject:correspondingLetter];
NSLog(@"------index:%i\ncorrespondingLetter: %@\ncorrespondingIndex: %i\n", index,correspondingLetter, correspondingIndex);
return correspondingIndex;
}
, , , , . , , . .
?
,