0

First off i would like to say i had a similar post like this but some how it just disappeared so if it reappears it was not intention to double post.

I created a uitableview with 3 sections and is being populated from 3 different arrays

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{ //Removed the bunch of code here to make it shorter

switch (indexPath.section) {
    case 0:
        cell.textLabel.text=[DogArray objectAtIndex:indexPath.row];
        break;
     case 1:
        cell.textLabel.text=[BirdArray objectAtIndex:indexPath.row];
        break;
    case 2:
        cell.textLabel.text=[FishArray objectAtIndex:indexPath.row];
       break;
    default:
        break;
}




[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;

}

Each of the three sections get their own values from their respective array.

The only problem is that. before i used one array so i would assign like this

 (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


if (checInt==0) 
{ 
    ThridView *summary=[[ThridView alloc]init];
    summary.detailViewController = detailViewController;
    self.detailViewController.receivedRainObject = [MainArray objectAtIndex:indexPath.row];//Pay attention to this line

This would pass in Pit bull,dove or swordfish to Summary base on who every was the .row....unfortunatly i cannot do this anymore since i use three different arrays. I was thinking of using a switch but even when i select swordfish from the fish array. NSLOG([DogArray objectAtIndex:indexPath.row]) shows me pitbull and NSLOG([BirdArray objectAtIndex:indexPath.row]) shows me dove so i cant say when those two are null .

Would love too know a way i could still pass in what every animal i select even if they come from different arrays, thanks

Sleep Paralysis
  • 449
  • 7
  • 22

1 Answers1

0

It seems to me that it should be the same logic you use for putting the text into the cell. That is, your index path's section chooses the array and the row chooses the offset.

Phillip Mills
  • 30,888
  • 4
  • 42
  • 57