次のコードを使用して、アプリケーション内のtableviewcontrollerを検索します。 現在の検索文字列は、テーブルリストのレストラン名と一致します。追加の文字列、場所を自分のコードと一致/検索したい。どのように私はこの機能に場所を追加することができます迅速なフィルタメソッドの第2パラメータ2.0
レストラン名変数 - restaurant.name、
レストランの場所変数 - restaurant.location
func filterContentForSearchText(searchText: String) {
searchResults = restaurants.filter({ (restaurant: Restaurant) -> Bool in let nameMatch = restaurant.name.rangeOfString(searchText, options:
NSStringCompareOptions.CaseInsensitiveSearch)
return nameMatch != nil
})
}
func updateSearchResultsForSearchController(searchController: UISearchController) {
let searchText = searchController.searchBar.text
filterContentForSearchText(searchText!)
tableView.reloadData()
}
どのように私は私のフィルタ法では、この追加のパラメータを追加することができますか?
ありがとうございますSumeet。出来た ! – Vinod