Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSArray *indexKeys = [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];
- NSMutableDictionary *grouped = [NSMutableDictionary dictionaryWithCapacity:[indexKeys count]];
- NSMutableArray *allMembersCopy = [NSMutableArray arrayWithArray:allMembers];
- [self sortMembersAlphabetically:allMembersCopy];
- NSString *firstChar;
- NSMutableArray *group;
- for (id key in indexKeys){
- group = [[NSMutableArray alloc] init];
- [grouped setObject:group forKey:key];
- [group release];
- group = nil;
- }
- for (id key in indexKeys){
- for (id memberVO in allMembersCopy){
- firstChar = [[[memberVO givenName] substringToIndex:1] lowercaseString];
- NSLog(@"firstChar: %@, key: %@", firstChar, key);
- if ([firstChar isEqualToString:key]){
- group = [grouped objectForKey:key];
- [group addObject:memberVO];
- }
- }
- }
- //NSLog(@"finished making dictionary: %@", grouped);
- NSLog(@"number of keyed sections in members dictionary: %d", [grouped count]);
- //TODO check retain/ se for previous version of list
- self.allMembersGrouped = grouped;
Add Comment
Please, Sign In to add comment