like contact list on device, that displays in section title like 'A' and after displaying contacts which are started from character 'A', and so on.
Here is my code that I am using in my app:
NSSortDescriptor *descriptorObj;This code removes the duplicate titles and sorts the list alphabetically.
descriptorObj = [[[NSSortDescriptor alloc] initWithKey:@"Name" ascending:YES] autorelease];
NSArray *arrayObj;
NSMutableArray *sectionTitlesArray = [tableDataSource valueForKey:@"Name"];
NSArray *arrayUniq;
arrayUniq = [[NSSet setWithArray:sectionTitlesArray] allObjects];
arrayObj = [uniquearray arrayObjUsingSelector:@selector(caseInsensitiveCompare:)];
Now I just need to convert the strings in the array to the first letters only.
Can anyone tell me the best way to do it?
Tarun Kumar
18-Nov-2015You can use this code: