Created
April 16, 2012 10:44
-
-
Save edwardinubuntu/2397642 to your computer and use it in GitHub Desktop.
sectionIndexTitlesForTableView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView { | |
NSMutableArray *toBeReturned = [[NSMutableArray alloc]init]; | |
for(char c = 'A';c<='Z';c++) | |
[toBeReturned addObject:[NSString stringWithFormat:@"%c",c]]; | |
return toBeReturned; | |
} | |
- (NSInteger)tableView:(UITableView *)tableView sectionForSectionIndexTitle:(NSString *)title atIndex:(NSInteger)index { | |
NSInteger count = 0; | |
NSMutableArray *arrayOfCharacters = [[NSMutableArray alloc]init]; | |
for(char c = 'A';c<='Z';c++) | |
[arrayOfCharacters addObject:[NSString stringWithFormat:@"%c",c]]; | |
for(NSString *character in arrayOfCharacters) { | |
if(title.length > 0 && [character isEqualToString:[title substringToIndex:1]]) | |
return count; | |
count ++; | |
} | |
return 0;// in case of some eror donot crash d application | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment