title: I get the wrong cell from the searchbar
body: <pre><code>var searchCountry = [String]() //to set up table
  var searching = false
  
  override func viewDidLoad() {
      super.viewDidLoad()
      // Do any additional setup after loading the view, typically from a nib.
  }
  
  override func didReceiveMemoryWarning() {
      super.didReceiveMemoryWarning()
      // Dispose of any resources that can be recreated.
  }
  
  
  }
  //table
  extension DictionaryViewController: UITableViewDataSource, UITableViewDelegate {
  func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -&gt; Int {
      if searching {
          return searchCountry.count
      } else {
      return countrynameArr.count
      }
  }
  
  func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
     let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
      if searching {
          cell.textLabel?.text = searchCountry[indexPath.row]
      } else {
          cell.textLabel?.text = countrynameArr[indexPath.row]
      }
      return cell
  }
  
  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
     myIndex = indexPath.row
      performSegue(withIdentifier: "segue0", sender: self)
  
  }
  }
  
  //Searchbar
  extension DictionaryViewController: UISearchBarDelegate {
  func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
     searchCountry = countrynameArr.filter({$0.lowercased().prefix(searchText.count) == searchText.lowercased()})
      searching = true
      tblView.reloadData()
  }
  
  
  func searchBarCancelButtonClicked(_ searchBar: UISearchBar) {
      searching = false
      searchBar.text = " "
      tblView.reloadData()
  }
  }
  </code></pre>
  
  <p>Hello everyone, it is the first time I do programming so my codes are probably terrible :). I created a tableview and a searchbar. When I scroll down the tableview and click on a item I get the right cell. When I use the searchbar I will get a filtered list (that is perfect) but then..when I click on the third item of the filtered list I get the third item form the whole list. Can you please tell me my mistake?</p>