0
Мне интересно, как сортировать китайский символ в «#» вместо A-Z.как отсортировать китайский символ в # в UILocalizedIndexedCollation
любые комментарии очень ценятся.
-(NSArray *)partitionObjects:(NSArray *)array collationStringSelector:(SEL)selector
{
self.collation = [UILocalizedIndexedCollation currentCollation];
NSInteger sectionCount = [[self.collation sectionTitles] count];//section count is take from sectionTitles and not sectionIndexTitles
NSMutableArray *unsortedSections = [NSMutableArray arrayWithCapacity:sectionCount];
//create an array to hold the data for each section
for(int i = 0; i < sectionCount; i++)
{
[unsortedSections addObject:[NSMutableArray array]];
}
//put each object into a section
for (id object in array)
{
NSInteger index = [self.collation sectionForObject:object collationStringSelector:selector];
[[unsortedSections objectAtIndex:index] addObject:object];
}
NSMutableArray *sections = [NSMutableArray arrayWithCapacity:sectionCount];
//sort each section
for (NSMutableArray *section in unsortedSections)
{
[sections addObject:[self.collation sortedArrayFromArray:section collationStringSelector:selector]];
}
return sections;
}
Я думаю, мой вопрос, почему вы используете UILocalizedIndexedCollation вообще. – matt
для индексации, но я хочу, чтобы китайский символ отсортировался на «#» вместо – Desmond
«Для индексирования». Но вы делаете все индексирование самостоятельно. Ваши данные не локализованы. Это просто английский алфавит плюс правило о китайском. Вы _fighting_ UILocalizedIndexedCollation, а не _using_ it. У вас будет более легкое время, если UILocalizedIndexedCollation вообще не будет в истории. – matt