Hello all, Im working on my project and stuck at point of searching through the tableView. I can't figure out how to change my code to filter position in my Categories (name and code). At this moment Search bar filters only Categories name, without category content.
Array:
var categories: [Category] = [
Category(name: "Name", sign: [Sign(code: "code", name: "name", description: "description", picture: "picture"),
My searchbar func which filter only categories ([Category])
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
filteredCategories = []
if searchText == "" {
filteredCategories = categories
} else {
for signs in categories {
if signs.name.lowercased().contains(searchText.lowercased()) {
filteredCategories.append(signs)
}
}
}
self.tableView.reloadData()
}
Thanks for your advices