У меня есть массив, содержащий словари, и я хочу показать значения в табличном представлении в соответствии с полем «имя» в каждом словаре. Предположим, что имя начинается с «а»; тогда «b» и «c» находятся в разных разделах. Количество разделов соответствует полю словарей словарей. Как я могу получить количество строк? Если кто-нибудь знает, пожалуйста, дайте решение.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
//---get the letter in each section; e.g., A, B, C, etc.---
NSString *alphabet = [subscribeIndexArray objectAtIndex:section];
//---get all states beginning with the letter---
//NSMutableArray *states =[[NSMutableArray alloc]init];
NSArray *states;
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF beginswith[c] %@", alphabet];
for(NSDictionary *dict in subscribeViewArray1)
{
states =[[dict valueForKey:@"name"] filteredArrayUsingPredicate:predicate];
}
//---return the number of states beginning with the letter---
return [states count];
}