title: How to clear SearchBar result and show full data in tableview using Swift?
body: <p>My Scenario, I am loading <code>JSON</code> data into <code>tableview</code> here I am maintaining two segment controller button for single <code>tableview</code> with <code>search-bar</code>. First segment button click to search I can get search result well and if I click segment button two there is also showing same search result. So, when I click segment one to two I need to clear search result and load normal data. Same scenario working well when I click close button within <code>searchBar</code>.</p>
  
  <p>My Code</p>
  
  <pre><code>@IBAction func switchTableviewAction(_ sender: UISegmentedControl) {
  
          switch sender.selectedSegmentIndex {
          case 0:
              print(“one”)
              self.searchResultClear()
              currentTableView = sender.selectedSegmentIndex
              self.tableView.reloadData()
  
          case 1:
              print(“two”)
              self.searchResultClear()
              currentTableView = sender.selectedSegmentIndex
              self.tableView.reloadData()
  
          default:
              break;
          }
      }
  
      // MARK: Search Result Clear working but not clearing result 
      func searchResultClear() {
          //self.searchBar.text = ""
          //self.searchBar.showsCancelButton = false
          //self.filteredLanguages.removeAll()
          //self.tableView.reloadData()
      }
  </code></pre>