Searching data from table view issue in swift : I have a search bar above my table view. The data in table view is coming from my service. I'm trying to apply search filter on the table view data. I have tried some code but it isn't working. My code for searchbar is this,

     var filteredData = [String]()
    var isSearching = false
    var dishNameArray = [String]()

    searchBar.delegate = self
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        if tableView == menuTableView{
            if isSearching{
                return filteredData.count
            }
        return ResMenuService.instance.categoryModelInstance.count
        }
        else{
        return AllReviewsService.instance.allReviewsModel.count
        }
    }
     func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        if tableView == menuTableView{
            let cell = menuTableView.dequeueReusableCell(withIdentifier: "menuCell", for: indexPath) as! RestaurantMenuTableViewCell
            
        if isSearching{
            
            cell.dishTitleLbl.text = filteredData[indexPath.row]
            dishNameArray.append(cell.dishTitleLbl.text!)
            
            }
//        let cell = menuTableView.dequeueReusableCell(withIdentifier: "menuCell", for: indexPath) as! RestaurantMenuTableViewCell
        
        cell.dishTitleLbl.text = ResMenuService.instance.categoryModelInstance[indexPath.row].categoryName
        cell.cardView.layer.cornerRadius = 5
        cell.selectionStyle = .none
        return cell
            
        }
        else
        {
            let cell = reviewTableView.dequeueReusableCell(withIdentifier: "reviewCell", for: indexPath) as! AllReviewsTableViewCell
            
            cell.nameLbl.text = AllReviewsService.instance.allReviewsModel[indexPath.row].name
            cell.descriptionLbl.text = AllReviewsService.instance.allReviewsModel[indexPath.row].description
            cell.timeLbl.text = AllReviewsService.instance.allReviewsModel[indexPath.row].time
            cell.ratingView.rating = Double(AllReviewsService.instance.allReviewsModel[indexPath.row].rating)
            cell.backgroundColor = UIColor.clear
            cell.selectionStyle = .none
            return cell
            
        }
    }

This is search bar delegate method.

    func updateSearchResults(for searchController: UISearchController) {
        filteredData.removeAll(keepingCapacity: false)
        let searchPredicate = NSPredicate(format: "SELF CONTAINS[c] %@", searchController.searchBar.text!)
        let array = (dishNameArray as NSArray).filtered(using: searchPredicate)
        filteredData = array as! [String]
        self.menuTableView.reloadData()
    }
But when i type something it does not filter the data. 