我正在尝试在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”的值
在
返回项目.BookedOrderId(共:searchText,选项:。不区分大小写,范围:nil,区域设置:nil)!=无
预订订单
是Int
谁能帮我一下吗。我困在这里什么也找不到。
Link Here
谢谢您。