self.collation = [UILocalizedIndexedCollation currentCollation];
NSInteger index, sectionTitlesCount = [[collation sectionTitles] count];
NSMutableArray *newSectionsArray = [[NSMutableArray alloc] initWithCapacity:sectionTitlesCount];
NSString *alphabet = [[NSString alloc] initWithString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"];
for (index = 0; index < sectionTitlesCount; index++) {
NSMutableArray *array = [[NSMutableArray alloc] init];
[newSectionsArray addObject:array];
NSString *letter = [alphabet substringWithRange:NSMakeRange(index, 1)];
[myDict setObject:newSectionsArray forKey:letter];
[array release];
}
'*** -[NSCFString substringWithRange:]: Range or index out of bounds'
for (Data *myData in self.dataModel.datalist) {
NSInteger sectionNumber = [collation sectionForObject:myData collationStringSelector:@selector(myName)];
NSMutableArray *sectionData = [newSectionsArray objectAtIndex:sectionNumber];
[sectionData addObject:myData];
}
sections = [NSArray arrayWithObjects:@"#", @"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];
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tView {
return [sections count];
}
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
return sections;
}
NSArray *sectionArray = [myData filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex:[indexPath section]]]];
for (index = 0; index < alphabet.length; index++) {