Question

Im trying to implement UILocalizedIndexCollection as seen on http://developer.apple.com/library/ios/#documentation/iPhone/Reference/UILocalizedIndexedCollation_Class/UILocalizedIndexedCollation.html

I get my address book after obtaining permission from the user which gives me an array of ABRecordRef's, and I have the following code to attempt to build the array of section arrays I need. However I have no idea what to put for collationStringSelectior. Any help would be amazing.

- (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];
}
Was it helpful?

Solution

You should use this code:

NSInteger section = [collation sectionForObject:name collationStringSelector:@selector(self)];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top