How to use search bar from within TableViewController.

I created a TableView Controller on the storyboard and embedded a search bar right above the prototype cell. In the side bar, it show it is the first item in the Table View. When I run the code, it shows the search bar but doesnt call searchBarTextDidEndEditing method.


All the links on the story board seem to be correct and I understand when you create the TableViewController by drag and drop, search bar outlets is not needed.


Pls help...what am I not doing right?



import UIKit

import Firebase

import FirebaseDatabase

class MyTableViewController: UITableViewController, UISearchBarDelegate {


/

var searchResults = " "


var personList = [ String]()


let queryDatabase = DatabaseOperations()


override func viewDidLoad() {

super.viewDidLoad()

}


func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {

searchResults = searchBar.text!

personList = queryDatabase.fetchPersons(searchResults: searchResults)

}

return

}



override func numberOfSections(in tableView: UITableView) -> Int {

return 1

}


override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

/

return personList.count

}



override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: "PersonCell", for: indexPath)

cell.textLabel?.text = personList[indexPath.row]

/

return cell

}