title: didSelectRowAtIndexPath indexpath after filter UISearchController - Swift
body: <p>I’m implementing a search bar with an UISearchController within a sectioned table. So far so good.</p>
  
  <p>The main issue is that when the the filtered results come along, it’s a whole new table with no sections and fewer rows.</p>
  
  <p>When selecting the row, I perform a segue to that position in the array, but the detailed view is expecting that exact row or index from the main array, which I can’t get from the filtered array of objects, which may be [0] [1] [2] in 300 elements.</p>
  
  <p>I guess I can compare the selected object with the main array and assuming there’s no duplicates, get the index from there and pass it over… But these seems pretty inefficient to me.</p>
  
  <p>Apple does something similar (I unfortunately don’t know how) when filtering Contacts, in the Contacts App. How they pass the contact object? That’s pretty much my goal.</p>
  
  <p>Here I let you a snippet of what I’m doing:</p>
  
  <pre><code>  func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
          if(self.resultSearchController.active) {
              customerAtIndex = indexPath.row // Issue here
              performSegueWithIdentifier("showCustomer", sender: nil)
          }
          else {
              customerAtIndex = returnPositionForThisIndexPath(indexPath, insideThisTable: tableView)
              performSegueWithIdentifier("showCustomer", sender: nil)
          }
      }
  
  override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
          if segue.identifier == "showCustomer" {
              if let destination = segue.destinationViewController as? CustomerDetailViewController {
                  destination.newCustomer = false
                  destination.customer = self.customerList[customerAtIndex!]
                  destination.customerAtIndex = self.customerAtIndex!
                  destination.customerList = self.customerList
              }
          }
      }
  </code></pre>