My solution consists of many other SO posts and Apple official documentation. It creates a view with a search bar in the UINavigationBar (so you need your navigation controller to be embedded, but you can change some lines to avoid this). Then you can select this SearchBar, and it will be a dull ViewController, then after entering some search it will be autocomplete, and when you click SearchButton the actual search will begin.
class ViewController: UISearchResultsUpdating, UISearchControllerDelegate, UISearchBarDelegate {
Then another direction is the one that gets called when the text in the search bar changes:
func updateSearchResultsForSearchController(searchController: UISearchController) { // If dismissed then no update if !searchController.active { return } // Write some code for autocomplete (or ignore next fonction and directly process your data hère and siplay it in the searchResultTCV) }
My choice is to leave updateSearchResultsForSearchControlller () to autofill, and then load the results when the user clicks on the search, so I have the last consequence:
func searchBarSearchButtonClicked(searchBar: UISearchBar) { if let search = searchController.searchBar.text {
user1585121
source share