I am trying to understand how to use the UISearchController when you want to display the results in a separate searchResultsController - each individual guide, video and tutorial that I found all used the current viewController to present the search results and create an instance of UISearchController as follows:
let searchController = UISearchController(searchResultsController: nil)
but I want to put out the view and introduce a new tableView with the search results, just like in the search on the App Store. So I created a new tableViewController, given its storyboard identifier, and then created it like this:
let storyboard = UIStoryboard(name: "Main", bundle: nil) let resultsController = storyboard.instantiateViewController(withIdentifier: "searchResults") as! UITableViewController let searchController = UISearchController(searchResultsController: resultsController )
which seems to work. However, I'm pretty stuck from here. I do not know how to display search results in control results, what to put in cellForRowAtIndexPath in resultsController, etc.
Any help is appreciated!
source share