title: How to filter and search with grouped tableview?
body: <p>I currently have 2 arrays </p>
  
  <p>expensesRecieved which is an array of type of array of expenses. so something like this [[Expense]].</p>
  
  <p>This contains a list of grouped expenses each associated with a date and the dates are stored in a separate array called expensesKeys which is of type string. </p>
  
  <p>I am trying to run a searchBar on this, which would allow me to only display expenses which contain the word searched and so far have this code:</p>
  
  <pre><code>func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
      if searchBar.text == nil || searchBar.text == ""{
          isSearching = false
          view.endEditing(true)
          tableView.reloadData()
      }
      else {
          isSearching = true
          for i in 0..&lt;expensesRecieved.count{
              for e in 0..&lt;expensesRecieved[i].count{
                  if ((expensesRecieved[i][e].name?.contains(searchBar.text!))! || expensesRecieved[i][e].categories!.title!.contains(searchBar.text!) || expensesRecieved[i][e].collections!.title!.contains(searchBar.text!)) {
  
                      filteredExpenses[i].append(expensesRecieved[i][e])
  
                  }
  
              }
          }
          tableView.reloadData()
  
      }
  }
  </code></pre>
  
  <p>and then in the cellForRowAt method, I have the following code</p>
  
  <pre><code>if isSearching{
          expense = self.filteredExpenses[indexPath.section][indexPath.row]
      }
      else{
          expense = self.expensesRecieved[indexPath.section][indexPath.row]
  
      }
  </code></pre>
  
  <p>however, I get a thread bad EXE on the second line. </p>
  
  <p>I have done search filtering before, but that was without a grouped tableview, so that is why I am confused. </p>