title: pushVC from filtered tableView
body: <p>I added a working SearchBar to my tableView - if I click on a cell from the unfiltered tableView, it get's me to the right second VC (chat controller)... but if I click on a cell from the filtered tableView, I get pushed to the secondVC from the cell of the unfiltered tableView - so if I filter a tableView and click on a cell from the filteredTableView, I actually click on the cell from the unfilteredTableView - I hope you understand my problem...</p>
  
  <p><strong>If not here is an example:</strong> The unfilteredTableView shows in the third cell the name "Alex3", now when I click on the cell I get to the Chat with "Alex3" - but if I filter the tableView for "John3" and click on the third cell I don't get to the chat with "John3", but to the Chat with "Alex3"</p>
  
  <p>This is the code:</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
      searchController.dismiss(animated: true, completion: nil)
      let user = self.users[indexPath.row]
      let chatLogController = ChatLogController(collectionViewLayout: UICollectionViewFlowLayout())
      chatLogController.user = user
      DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
          self.navigationController?.pushViewController(chatLogController, animated: true)
      }
  }
  </code></pre>
  
  <p>Code for SearchBar/Controller:</p>
  
  <pre><code>override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      if isFiltering() {
          return filtered.count
      }
      return users.count
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
      let cell = tableView.dequeueReusableCell(withIdentifier: cellId, for: indexPath) as! UserCell
      var user = users[indexPath.row]
      cell.textLabel?.text = user.name
      if isFiltering() {
          user = filtered[indexPath.row]
      } else {
          user = users[indexPath.row]
      }
      cell.textLabel!.text = user.name
  
      return cell
  }
  
  //UISearchBar
  func searchBarIsEmpty() -&gt; Bool {
      // Returns true if the text is empty or nil
      return searchController.searchBar.text?.isEmpty ?? true
  }
  
  func isFiltering() -&gt; Bool {
      return searchController.isActive &amp;&amp; !searchBarIsEmpty()
  }
  
  func filterContentForSearchText(_ searchText: String, scope: String = "All") {
      filtered = users.filter({( user : User) -&gt; Bool in
          return (user.name?.lowercased().contains(searchText.lowercased()))!
      })
      tableView.reloadData()
  }
  
  
  }
  
  extension NewMessageController: UISearchResultsUpdating {
  // MARK: - UISearchResultsUpdating Delegate
  func updateSearchResults(for searchController: UISearchController) {
      filterContentForSearchText(searchController.searchBar.text!)
      }
  }
  </code></pre>