Search code examples
uitableviewxcode4

One segue identifier used between two UIViewControllers for multiple UITableView cell data transfer?


In this case, I am assigning values below to stringToDisplay and want to send them to SegViewController, which also retains stringToDisplay. Do I need to use cell.textLabel.text here with isEqualToString: @"Fire House Gallery? Would I use indexPath or UITableViewCell here?

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
  SegViewController *seg = segue.destinationViewController;
  seg.delegate = (id)self;

  if ("......" isEqualToString: @"Firehouse Gallery"])
  {
      seg.stringToDisplay = @"Firehouse Gallery";
  }
  else
  {
      seg.stringToDisplay = @"Frog Hollow Craft Center";
  }
}

Thank you, Greg


Solution

  • I found an answer for what I was looking for. I now have ONE segue link between two UIViewcontrollers, with the segue identifier called @"seg". For a place named Radio Bean, I use the following when the "Radio Bean" cell is pressed:

    if ([cell.textLabel.text isEqualToString: @"Radio Bean"])
    {
         self.stringToDisplay = @"Radio Bean";
         [self performSegueWithIdentifier:@"seg" sender:self];
    }
    

    Then, in prepareForSegue I DO NOT specify segue identifier but use the following:

    - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
    {
       SegViewController *seg = segue.destinationViewController;
       seg.delegate = (id)self;
    
       if ([self.stringToDisplay isEqualToString: @"Radio Bean"])
       {
           seg.stringToDisplay = @"Radio Bean";
       }
    }
    

    This successfully passes "Radio Bean" to the next UIViewcontroller, and I can include multiple place options with the use of only ONE segue link, so, no need for multiple links.