       let now = NSDate()
       let updateString = "Last Updated at " + self.dateFormatter.stringFromDate(now)
       self.refreshControl?.attributedTitle = NSAttributedString(string: updateString)
-
+      
       self.tableView.reloadData()
+    }
+    
+    switch gistSegmentedControl.selectedSegmentIndex {
+      case 0:
+        GitHubAPIManager.sharedInstance.fetchPublicGists(urlToLoad, completionHandler:
+          completionHandler)
+      case 1:
+        GitHubAPIManager.sharedInstance.fetchMyStarredGists(urlToLoad, completionHandler:
+          completionHandler)
+      case 2:
+        GitHubAPIManager.sharedInstance.fetchMyGists(urlToLoad, completionHandler:
+          completionHandler)
+      default:
+        print("got an index that I didn't expect for selectedSegmentIndex")
     }
   }
   

  
  func loadGists(urlToLoad: String?) {
    self.isLoading = true
    GitHubAPIManager.sharedInstance.fetchMyStarredGists(urlToLoad) { (result, nextPage) in
      self.isLoading = false
      self.nextPageURLString = nextPage
      

  }
  
  @IBAction func segmentedControlValueChanged(sender: UISegmentedControl) {
    // clear out the table view
    gists = []
    tableView.reloadData()
    // then load the new list of gists
    loadGists(nil)
  }
}
