I want to search for the key id in the dictionary. I have a dictionary like this:
var tableData:[String:Any] = ["id":["path":"","type":"","parameters":[]]]
Table data has 307 items, and all id's unique. I want to search in dictionary key id, like when I write "get" , it need the show all the search results with "get" in table view.
func updateSearchResults(for searchController: UISearchController) {
let searchString = searchController.searchBar.text
if let entry = tableData.keys.first(where: { $0.lowercased().contains(searchString) }) {
print(entry)
} else {
print("no match")
}
tableView.reloadData()
}
func didChangeSearchText(searchText: String) {
if let entry = tableData.keys.first(where: { $0.lowercased().contains(searchText) }) {
print(entry)
} else {
print("no match")
}
// Reload the tableview.
tableView.reloadData()
}
When I try to search a word it prints "no match", in the debug, unable to read data writes for the value of the entry. Thank you in advance!