             self.tableView.reloadData()
             
         }
-        
+    }
+    
+    func refresh(sender : AnyObject)
+    {
+        nextPageURLString = nil
+        loadGists(urlToLoad: nil)
     }
 
 }

            self.nextPageURLString = nextPage
            self.isLoading = false
            
            guard result.error == nil else
            {
                print(result.error!)


    override func viewWillAppear(_ animated: Bool) {
        self.clearsSelectionOnViewWillAppear = self.splitViewController!.isCollapsed
        
        if( self.refreshControl == nil) {
            self.refreshControl = UIRefreshControl()
            self.refreshControl?.addTarget(self, action: #selector(MasterViewController.refresh(sender:)), for: UIControlEvents.valueChanged)
        }
        
        // initial the gist view
        if(nextPageURLString == nil) {
            loadGists(urlToLoad: nil)
        }
        
        super.viewWillAppear(animated)
        //loadGists(urlToLoad: nextPageURLString)
        
        
        //GitHubAPIManager.sharedInstance.getStarredGistWithBasicAuth()
    }

