         // on the view controller in which you want the search to be presented.
         definesPresentationContext = true
         
+        searchController.searchResultsUpdater = self
+        searchController.dimsBackgroundDuringPresentation = false
+        
         // Uncomment the following line to preserve selection between presentations
         // self.clearsSelectionOnViewWillAppear = false
 

import UIKit
import CoreData

class RestaurantTableViewController: UITableViewController, NSFetchedResultsControllerDelegate {

    var restaurantNames = ["Cafe Deadend", "Homei", "Teakha", "Cafe Loisl",
        "Petite Oyster", "For Kee Restaurant", "Po's Atelier",

        tableView.endUpdates()
    }
    
    // search bar code
    // following is the search logic. Its simple, uses filter
    func filterContentForSearchText(searchText: String!) {
        searchResults = restaurants.filter() { (restaurant: Restaurant) -> Bool in
            let nameMatch = restaurant.name.rangeOfString(searchText, options: .CaseInsensitiveSearch)
            return nameMatch != nil
        }
    }
    
    // When a user selects the search bar or makes any changes inside it, 
    // this method will be called. By implementing the method, we can instruct
    // the search controller to display the search results
    func updateSearchResultsForSearchController(searchController: UISearchController) {
        let searchText = searchController.searchBar.text
        filterContentForSearchText(searchText)
        tableView.reloadData()
    }
    
    override func prefersStatusBarHidden() -> Bool {
        return false
    }
