The search bar in the weekly view controller in my app isn't working. It fails to show the corresponding cell from the text in the search bar. Project: link:https://github.com/lexypaul13/Trending-Tv-Shows
Code Block isSearching = False func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { var activeArray: Show if isSearching { activeArray = shows[indexPath.row] } else { activeArray = filteredShows[indexPath.row] } let detailsVC = Details_ViewController(showID:show_ID) detailsVC.showID = activeArray.id ?? 0 let navController = UINavigationController(rootViewController: detailsVC) present(navController, animated: true) } func updateUI(_ shows:[Show]){ if self.shows.isEmpty{ let alert = UIAlertController(title: "Tv Show Doesnt Exist", message: nil,preferredStyle: UIAlertController.Style.alert) alert.addAction(UIAlertAction(title: "OK", style: UIAlertAction.Style.default, handler: nil)) self.present(alert, animated: true, completion: nil) } self.updateData(shows: self.shows) } func updateData(shows:[Show]){ //shows follwers var snapshot = NSDiffableDataSourceSnapshot<Section,Show>() snapshot.appendSections([.main]) snapshot.appendItems(shows) DispatchQueue.main.async { self.dataSource.apply(snapshot,animatingDifferences: true) } } func updateSearchResults(for searchController: UISearchController) { if searchController.searchBar.text != ""{ filteredShows = shows.filter({$0.unwrappedName.lowercased().contains((searchController.searchBar.text ?? "").lowercased())}) updateData(shows: filteredShows) } else { updateData(shows: shows) } } func searchBarSearchButtonClicked(_ searchBar: UISearchBar) { isSearching = false updateData(shows: filteredShows) }