Я пытаюсь реализовать функцию поиска в моем UITableViewController. Поэтому я добавил контроллер поиска поверх ячейки внутри UITableView.
Я сделал это UISearchBarDelegate
с помощью моего TableViewController.
Вот мой код для фильтрации поискового текста:
// This method updates filteredData based on the text in the Search Box
func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) {
// When there is no text, filteredData is the same as the original data
// When user has entered text into the search box
// Use the filter method to iterate over all items in the data array
// For each item, return true if the item should be included and false if the
// item should NOT be included
filteredData = searchText.isEmpty ? OrderDetailsTabBarViewController.orderDetailsList : OrderDetailsTabBarViewController.orderDetailsList.filter { (item: OrderBookedSetterGetter) -> Bool in
// If dataItem matches the searchText, return true to include it
return item.BookedOrderId(of: searchText, options: .caseInsensitive, range: nil, locale: nil) != nil
}
tableView.reloadData()
}
Но это показывает ошибку Невозможно вызвать значение нефункционального типа 'Int' в return item.BookedOrderId (of: searchText, options: .caseInsensitive, range: nil, locale: ноль)! = ноль строка.
BookedOrderId - это Int
Может ли кто-нибудь помочь мне с этим. Я застрял здесь и не могу ничего найти.
Кроме того, я следовал этому уроку:
Ссылка здесь
Спасибо.