forum

Home / DeveloperSection / Forums / return an array for section titles in table view

return an array for section titles in table view

Anonymous User 1308 18-Nov-2015
I want to create an array for section titles because section titles are the first letter for the items in the section.
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;
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:)];
This code removes the duplicate titles and sorts the list alphabetically.
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?


Updated on 18-Nov-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By