- (NSArray *)dataSourceForIndividuals:(NSArray *)individuals {
// Assumption: displayNames are sorted alphabetically
NSUInteger sectionIndexTitlesCount = [[self sectionIndexTitles] count];
NSMutableArray *dataSource = [NSMutableArray arrayWithCapacity:sectionIndexTitlesCount];
NSUInteger index = 0;
for (index = 0; index < sectionIndexTitlesCount; index++) {
[dataSource addObject:[NSMutableArray array]];
}
SEL selector = @selector(displayName);
index = 0;
for (TDTIndividual *individual in individuals) {
NSInteger sectionNumber = [[UILocalizedIndexedCollation currentCollation] sectionForObject:individual collationStringSelector:selector];
[[dataSource objectAtIndex:(NSUInteger)sectionNumber] addObject:individual.objectID];
++index;
}
return dataSource;
}
Приведенный выше код работает нормально, но время, затраченное вторым на цикл, слишком велико, если число людей велико, есть ли лучший способ сделать это?Очень высокое время загрузки секционированного UITableView
@MartinR Вы совершенно правы. Хотя это никогда не было проблемой: p. Я не могу вспомнить, почему у меня была эта идея. Я давно прочитал оба сообщения, и я получил эту идею. Спасибо, что исправил меня :) –