JAHelia
JAHelia

Reputation: 7922

how to get the UISearchController's search results table view

I defined a UISearchController instance like this:

let searchController = UISearchController(searchResultsController: nil) 

but cannot find a way to get a reference to its search results table view.
previously using UISearchDisplayController it's easy as:

self.searchDisplayController?.searchResultsTableView.reloadData()

p.s. I know that if I define it like:

let searchController = UISearchController(searchResultsController: aTableViewControllerInstance)

then the search results table view will be aTableViewControllerInstance.tableView but in my case I didn't use a table view controller.

Upvotes: 0

Views: 1819

Answers (1)

Michael
Michael

Reputation: 9044

When you have the following line:

    let searchController = UISearchController(searchResultsController: nil)

This is not saying that there is no search results controller, it is saying the search results controller is the same view controller as in which it appears. Therefore the results tableView is your current view controller's tableView (ie. self.tableView).

Have you set searchResultsUpdater? It is here you need to filter as appropriate, and so you will have the results available.

A good example of what you want to do is here.

Upvotes: 2

Related Questions