title: How to check SearchController is active or not before click UITableview cell using Swift
body: <p>I am implementing <code>SearchController</code> with <code>tableview</code> data. Here, Once searched particular data after that clicking search result cell to moving another detail page. Now, If I comeback to main view controller search controller showing without dismissing. I tried below code Its working fine for detail to main viewcontroller scenario but If I click cell without search text then its making crash. How to fix it?</p>
  
  <pre><code>    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
  
    let section = isFiltering ? filteredSections[indexPath.section] : sections[indexPath.section] // without search text I am getting index out of range issue
          let item = section.result[indexPath.row]
  
                  let detailsVC = self.storyboard?.instantiateViewController(withIdentifier: "detailviewcontroller") as! DetailViewController
                  let navigationController = UINavigationController(rootViewController: detailsVC)
                  self.present(navigationController, animated: true, completion: nil)
  
  
              // Search Dismiss - without search text if click tableview cell I am getting crash 
              // MARK: Validate SearchController isActive or Not.
          if searchController != nil {
              // Get rid of searchController
              searchController.searchBar.endEditing(true)
              searchController.isActive = false
              searchController.dismiss(animated: true) { /* */ }
          }
          }
  </code></pre>