Advertisement
Guest User

Untitled

a guest
Jul 6th, 2013
736
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  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++) {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement