gpt4 book ai didi

ios - 如何按部分对 iOS 中的地址簿条目进行排序

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:47:15 25 4
gpt4 key购买 nike

我正在尝试实现 UILocalizedIndexCollection,如上所见 http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalizedIndexedCollation_Class/UILocalizedIndexedCollation.html

在获得用户的许可后,我得到了我的地址簿,这给了我一个 ABRecordRef 的数组,并且我有以下代码来尝试构建我需要的部分数组的数组。但是我不知道为 collat​​ionStringSelectior 放什么。任何帮助都会很棒。

- (void)setListContent:(NSArray *)inListContent
{
if (listContent == inListContent) {
return;
}
[listContent release]; listContent = [inListContent retain];

NSMutableArray *sections = [NSMutableArray array];
UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation];
for (int i=0;i < [listContent count];i++) {
ABRecordRef person=[listContent objectAtIndex:i];
NSLog(@"person name is ");
NSString* name = (NSString *)(ABRecordCopyCompositeName(person));
NSLog(name);
NSInteger section = [collation sectionForObject:person collationStringSelector:@selector(????)];
[sections addObject:person toSubarrayAtIndex:section];
}

NSInteger section = 0;
for (section = 0; section < [sections count]; section++) {
NSArray *sortedSubarray = [collation sortedArrayFromArray:[sections objectAtIndex:section]
collationStringSelector:@selector(name)];
[sections replaceObjectAtIndex:section withObject:sortedSubarray];
}
[sectionedListContent release];
sectionedListContent = [sections retain];
}

最佳答案

你应该使用这段代码:

NSInteger section = [collation sectionForObject:name collationStringSelector:@selector(self)];

关于ios - 如何按部分对 iOS 中的地址簿条目进行排序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13426396/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com