私はここにコード上記のコード配列flashcardsNamesListでiphoneのnsdictionaryから値を取得する方法は?
-(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];
}
}
がある関数を呼び出すときに、flashCardsIdは毎回変わる配列 で辞書を埋めるための関数を使用しています[自己getFlashCard:J ]; jはlistOfCategoryId配列から来るcategoryidを変更するパラメータです。
辞書から値を取得する方法uitableviewの異なるセクションに異なるflashcardsNamesを表示したいのですが。ここ
は値
- (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
は
メソッドが実装されているオブジェクトをテーブルビューのデータソースとして設定しましたか? これはどういう意味ですか? numberOfRowsInSection:メソッドが呼び出されますが、このラインの戻り配列の0オブジェクト にNSArray *配列= [辞書objectForKey:@「フラッシュカード」] –
私の編集 –
方法のtableViewを見てみましょう。 私はここにこだわっています.. –