Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Jul 6th, 2013  |  syntax: None  |  size: 1.59 KB  |  views: 31  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. self.collation = [UILocalizedIndexedCollation currentCollation];
  2.  
  3. NSInteger index, sectionTitlesCount = [[collation sectionTitles] count];
  4.  
  5. NSMutableArray *newSectionsArray = [[NSMutableArray alloc] initWithCapacity:sectionTitlesCount];
  6.  
  7. NSString *alphabet = [[NSString alloc] initWithString:@"ABCDEFGHIJKLMNOPQRSTUVWXYZ"];
  8.  
  9. for (index = 0; index < sectionTitlesCount; index++) {
  10.     NSMutableArray *array = [[NSMutableArray alloc] init];
  11.     [newSectionsArray addObject:array];
  12.  
  13.     NSString *letter = [alphabet substringWithRange:NSMakeRange(index, 1)];
  14.     [myDict setObject:newSectionsArray forKey:letter];
  15.  
  16.     [array release];
  17. }
  18.        
  19. '*** -[NSCFString substringWithRange:]: Range or index out of bounds'
  20.        
  21. for (Data *myData in self.dataModel.datalist) {
  22.  
  23.     NSInteger sectionNumber = [collation sectionForObject:myData collationStringSelector:@selector(myName)];
  24.  
  25.     NSMutableArray *sectionData = [newSectionsArray objectAtIndex:sectionNumber];
  26.  
  27.     [sectionData addObject:myData];
  28.  
  29. }
  30.        
  31. sections = [NSArray arrayWithObjects:@"#", @"a", @"b", @"c", @"d", @"e", @"f", @"g", @"h", @"i", @"j", @"k", @"l", @"m", @"n", @"o", @"p", @"q", @"r", @"s", @"t", @"u", @"v", @"w", @"x", @"y", @"z", nil];
  32.        
  33. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tView {
  34.     return [sections count];
  35. }
  36.  
  37.  
  38. - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView {
  39.     return sections;
  40. }
  41.        
  42. NSArray *sectionArray = [myData filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", [sections objectAtIndex:[indexPath section]]]];
  43.        
  44. for (index = 0; index < alphabet.length; index++) {
clone this paste RAW Paste Data