0
我有一個包含字典的數組,我想根據每個字典中的「名稱」字段在表視圖中顯示值。假設名字以「a」開頭;那麼「b」和「c」在不同的部分。部分的數量對應於字典的「名稱」字段。我如何獲得行數?如果有人知道,請給解決方案。NSPredicate協助數組中的對象
- (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];
}
我已經這樣做了,但我想你separting與名稱值數組整部字典 – parvind 2010-10-30 05:58:14