я использую функцию для заполнения словаря в массиве
вот код
-(void)getAllFlashCardsNames
{
if ([listofitems count]==0)
listofitems = [[NSMutableArray alloc] init];
else
[listofitems removeAllObjects];
for(int i=0;i<listOfCategoryId.count;i++)
{
int j=[[listOfCategoryId objectAtIndex:i]intValue];
[self getFlashCard:j];
NSArray *flashCardsNames = flashCardsNamesList;
NSArray *flashCardsids = flashCardsId;
NSLog(@"FLash Card Ids %@",flashCardsids);
NSDictionary *dictionary = [NSDictionary dictionaryWithObjectsAndKeys:flashCardsNames,@"flashCards",flashCardsids,@"flashCardId",nil];
[listofitems addObject:dictionary];
}
}
в приведенном выше коде массив flashcardsNamesList, flashCardsId изменяется каждый раз при вызове функции [self getFlashCard: j]; j - параметр для изменения categoryid, который поступает из массива listOfCategoryId ..
теперь, как мне извлечь значения из словаря, я хочу показать разные flashcardsNames в разных разделах в uitableview.
вот код, который я использую для получения значений
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return [listofitems count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection: (NSInteger)section {
NSDictionary *dictionary =[listofitems objectAtIndex:section];
NSLog(@"dictionary=%@",dictionary);
NSArray *array =[dictionary objectForKey:@"flashCards"];
NSLog(@"array=%@",array);
NSLog(@"Section Count = %d",array.count);
return array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell *)[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
NSDictionary *dictionary =[listofitems objectAtIndex:indexPath.section];
NSArray *array =[dictionary objectForKey:@"flashCards"];
NSArray *array1=[dictionary objectForKey:@"flashCardId"];
NSString *cellValue=[array objectAtIndex:indexPath.row];
NSString *cellValue1=[array1 objectAtIndex:indexPath.row];
[cell.FlashCardsNames setText:cellValue];
[cell setFlashCardId:[cellValue1 intValue]];
return cell;
}
но метод
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
не вызывается