난이 배열 여기 로 사전 충전하는 기능을 사용하고하기 기능 [자기 getFlashCard 호출시 배열 flashcardsNamesList가 flashCardsId 매번 변화 위의 코드에서 코드아이폰의 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];
}
}
에게이다 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
이
메서드가 구현 된 개체를 테이블보기의 데이터 원본으로 설정 했습니까? 이것은 무엇을 의미합니까 ??? –
내 편집 –
에서 tableView : numberOfRowsInSection : 메서드가 호출되었지만이 줄은 배열의 0 개 객체를 반환합니다. NSArray * array = [dictionary objectForKey : @ "flashCards"]; 나는 여기에 갇혀있다. –