Hallo,
ich habe eine UITableView mit 2 Sections. Die erste soll 2 Zeilen beinhalten und die andere 4. Nun hab ich zwei Dictionarys, mit 2 bzw. 4 Einträgen. Nun sollen mit dem ersten Dictionary die erste Section gefüllt werden und mit dem 2. die 2. Section.
Habe folgenden Code:
Alles anzeigen
Als Exception bekomm ich *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSArray objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
Was ich nicht verstehe, da es ja passen müsste. Habe 2 Einträge in dicTable.
Was mache ich falsch, bzw. wie kann ich verschieden große Sections mit Daten füllen?
Vielen Dank & Grüße,
Andre
ich habe eine UITableView mit 2 Sections. Die erste soll 2 Zeilen beinhalten und die andere 4. Nun hab ich zwei Dictionarys, mit 2 bzw. 4 Einträgen. Nun sollen mit dem ersten Dictionary die erste Section gefüllt werden und mit dem 2. die 2. Section.
Habe folgenden Code:
PHP-Quellcode
- ...
- dicTable = [[NSMutableDictionary alloc] init];
- dicTable1 = [[NSMutableDictionary alloc] init];
- [dicTable setObject:aSN.plant forKey:@"Plant"];
- [dicTable setObject:aSN.workplace forKey:@"Workplace"];
- [dicTable1 setObject:aSN.startDate forKey:@"Event Start"];
- [dicTable1 setObject:aSN.endDate forKey:@"Event End"];
- [dicTable1 setObject:aSN.category forKey:@"Category"];
- [dicTable1 setObject:aSN.referenceObject forKey:@"Reference Object"];...
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
- static NSString *CellIdentifier = @"Custom";
- ShiftNoteDetailsCell *cell = (SNDetailsCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SNDetailsCell" owner:self options:nil];
- cell = (SNDetailsCell *)[nib objectAtIndex:0];
- }
- if(currentSection == 0){
- cell.description.text = [[self.dicTable allKeys] objectAtIndex:indexPath.row];
- cell.value.text = [[self.dicTable allValues] objectAtIndex:indexPath.row];
- }else{
- cell.description.text = [[self.dicTable1 allKeys] objectAtIndex:indexPath.row];
- cell.value.text = [[self.dicTable1 allValues] objectAtIndex:indexPath.row];
- }
- return cell;
- }
- - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
- // Return the number of rows in the section.
- if(section == 0){
- currentSection = 0;
- return [dicTable count];
- }else{
- currentSection = 1;
- return [dicTable1 count];
- }
- }
Als Exception bekomm ich *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[NSArray objectAtIndex:]: index 2 beyond bounds [0 .. 1]'
Was ich nicht verstehe, da es ja passen müsste. Habe 2 Einträge in dicTable.
Was mache ich falsch, bzw. wie kann ich verschieden große Sections mit Daten füllen?
Vielen Dank & Grüße,
Andre