   func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
     var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell
     var foodName: String
-    
-    if self.searchController.active && self.searchString! != "" {
-      foodName = filteredSuggestedSearchFoods[indexPath.row]
+    let selectedScopeButtonIndex = self.searchController.searchBar.selectedScopeButtonIndex
+    if selectedScopeButtonIndex == 0 {
+      if self.searchController.active && self.searchString! != "" {
+        foodName = filteredSuggestedSearchFoods[indexPath.row]
+      } else {
+        foodName = suggestedSearchFoods[indexPath.row]
+      }
+    }
+    else if selectedScopeButtonIndex == 1 {
+      foodName = apiSearchForFoods[indexPath.row].name
     } else {
-      foodName = suggestedSearchFoods[indexPath.row]
+      foodName = ""
     }
-    
     cell.textLabel?.text = foodName
     cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
     return cell
   }
   
   func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
-    if self.searchController.active && self.searchString! != "" {
-      return self.filteredSuggestedSearchFoods.count
-    } else {
-      return self.suggestedSearchFoods.count
+    let selectedScopeButtonIndex = self.searchController.searchBar.selectedScopeButtonIndex
+    if selectedScopeButtonIndex == 0 {
+      if self.searchController.active && self.searchString! != "" {
+        return self.filteredSuggestedSearchFoods.count
+      } else {
+        return self.suggestedSearchFoods.count
+      }
+    }
+    else if selectedScopeButtonIndex == 1 {
+      return self.apiSearchForFoods.count
+    }
+    else {
+      return 0
     }
   }
 }

  var searchController: UISearchController!
  var suggestedSearchFoods: [String] = []
  var filteredSuggestedSearchFoods: [String] = []
  var searchString: String?
  var scopeButtonTitles = ["Recommended", "Search Results", "Saved"]
  
  override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.

// MARK: UISearchBarDelegate
extension ViewController: UISearchBarDelegate {
  func searchBarSearchButtonClicked(searchBar: UISearchBar) {
    self.searchController.searchBar.selectedScopeButtonIndex = 1
    makeRequest(searchBar.text)
  }
}
