My question is I have implemented UISearchController
in Swift 3 when I tried to filter it\'s easily filtered simple array but my case is little bit different I have
Can we just use Swift's built in filter
method?
func updateSearchResults(for searchController: UISearchController) {
self.tableView.reloadData()
self.filteredRecipeArray.removeAll(keepingCapacity: false)
guard let searchText = searchController.searchBar.text else {
return
}
let array = managerArray.filter {
return $0.id.range(of: searchText) != nil ||
$0.title .range(of: searchText) != nil ||
$0.ManagerDesignation.range(of: searchText) != nil
}
self.filteredRecipeArray = array
self.tableView.reloadData()
}
EDIT
Updated the answer to latest Swift 3 syntax