title: Search bar and sections in tableview using swift3
body: <p>I have tableview with alphabetic sections from my database and I want to add search bar but i can't figure it out how to filter the data and implement it in the tableview. 
  My database store inside two structs:</p>
  
  <p>one struct holding all the data.</p>
  
  <p>second struct gets the first letter for the sections and the first struct as array.</p>
  
  <p>My structs:</p>
  
  <pre><code>struct SentenceInfo { // First struct (holds all the data)
  
      let name: String
      let detail: String
      let sentence: String
  
      init(name: String, detail: String, sentence: String) {
          self.name = name
          self.detail = detail
          self.sentence = sentence
      }
  }
  
  struct SentenceNameSection { // Second struct (first letter and array of the first struct)
  
      var firstLetter: String
      var crimes: [SentenceInfo]
  
      init(title: String, objects: [SentenceInfo]) {
          firstLetter = title
          crimes = objects
      }
  }
  </code></pre>
  
  <p>My tableView:</p>
  
  <pre><code>var sections : [SentenceNameSection]!
  
  var crimeData = [SentenceNameSection]()
  
  var filteredData = [SentenceNameSection]()
  
  var shouldShowSearchResults = false
  
  var searchController: UISearchController!
  
  
  func updateSearchResults(for searchController: UISearchController) {
  
      let searchString = searchController.searchBar.text
  
      filteredData = crimeData.filter({ (crime) -&gt; Bool in
          let crimeMatch: String = crime // Error about types
      return ((crimeMatch.range(of: searchString!) != nil))
      })
  }
  
  override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -&gt; UITableViewCell {
  
      let cell: sentenceTableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifer, for: indexPath) as! sentenceTableViewCell
  
      let crime: SentenceInfo = sections[indexPath.section].crimes[indexPath.row]
  
      cell.nameLabel.text = crime.name
      cell.detailLabel.text = crime.detail
      cell.sentenceLabel.text = crime.sentence
  
      return cell
  }
  </code></pre>