title: How to show data with Search Bar and Search Display Controller in other View Controller
body: <p>thanks in advance. </p>
  
  <p>I'm trying to create an app that has arrays with names, pictures and numbers. I already have the table view created with all the data in the respective arrays; I already have the Search bar working and displaying the correct search. What I'm missing is showing the results of the search bar in another view controller. (I already got this working with the Table View: I select a name and it opens another view and then show me the picture and the number etc,) I'm just missing the same thing but when I do the search.</p>
  
  <p>Here is my code.</p>
  
  <pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
      static NSString *simpleTableIdentifier = @"DreamCell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
  
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
      }
  
      if (tableView == self.tableView) {
         cell.textLabel.text = [Names objectAtIndex:indexPath.row];
          cell.imageView.image =[UIImage imageNamed:[Images objectAtIndex:indexPath.row]];
      } else{
          cell.textLabel.text = [searchResults objectAtIndex:indexPath.row];
      }
      return cell;
  }
  
  - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
      if (self.searchDisplayController.isActive) {
         [self performSegueWithIdentifier:@"ShowDreamsDetails" sender:self];
      }
  }
  
  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender  {
      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
      if ([segue.identifier isEqualToString:@"ShowDreamsDetails"])  {
          NSString *object =nil;
          //  NSIndexPath *indexPath =nil;
  
          if (self.searchDisplayController.isActive) {
              indexPath =[[self.searchDisplayController searchResultsTableView] indexPathForSelectedRow];
              object = [searchResults objectAtIndex:indexPath.row];
  
              /* *Here is where I have the problem, If I leave it like thi,s it only shows         the first row in my array; I needed to send the correct name and details to the other View Controller.   */
  
              DesciptionViewController *desViewController = segue.destinationViewController;
              desViewController.PrincipalName = [Names objectAtIndex:indexPath.row ];
              desViewController.PrincipalDescription = [Description objectAtIndex:indexPath.row];
              desViewController.PrincipalNumber = [Numeros objectAtIndex:indexPath.row];
              desViewController.Images1 = [UIImage imageNamed: [Images objectAtIndex: indexPath.row]];  
          } else {
              DesciptionViewController *desViewController = segue.destinationViewController;
              desViewController.PrincipalName = [Names objectAtIndex:indexPath.row];
              desViewController.PrincipalDescription = [Description objectAtIndex:indexPath.row];
              desViewController.PrincipalNumber = [Numeros objectAtIndex:indexPath.row];
              desViewController.Images1 = [UIImage imageNamed: [Images objectAtIndex: indexPath.row]];
  
          }
      }
  }
  </code></pre>
  
  <p>Thanks in advance to anyone, and I'm sorry if this is a duplicate question; I tried to search around, but I did not find anything. </p>