Adding search ability to tableview
<p>Am trying to add search ability to my app I added <code>search bar</code> to <code>nav bar</code> <em>programmatically</em> using this code</p>

<pre><code>func addSearch(){
    searchBar.showsCancelButton = false
    searchBar.placeholder = "Search"
    searchBar.delegate = self
    self.navigationItem.titleView = searchBar
}
</code></pre>

<p>I added the function to an <code>IBAction</code> I added delegate <code>UISearchBarDelegate</code>
also I have the following <code>var food = [Food]()</code>, 
<code>var filteredProducts =[Food]()</code>  </p>

<p>I have this delegate methods</p>

<pre><code>func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {
    if searchBar.text != nil || searchBar.text ==  ""{
        inSearchMode = false
        view.endEditing(true)
        tableView.reloadData()

    }else{
        inSearchMode = true
        let lower = searchBar.text!.lowercaseString
        filteredProducts = food.filter({$0.store_name.rangeOfString(searchBar.text!) != nil})
        tableView.reloadData()
    }
}
</code></pre>

<p>and i have everything setup in my tableView delegates but when i search it doesnt work</p>