             textFieldPerson.text = personInfo
         }
         tableView.reloadData()
+        
+    }
+    
+    // MARK: Table View functions
+    
+    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
+        
+        return items.count
+        
+    }
+    
+    //load the table view based off the items array
+    func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
+        
+        let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
+        cell.textLabel?.text = items[indexPath.row]
+        
+        return cell
+        
+    }
+    
+    //When the user clicks on a tableview cell the SI name in that cell is put in the SI name textfield
+    func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
+        
+        let autoCompleteString = items[indexPath.row]
+        let returnString = autoCompleteString.componentsSeparatedByString(" ")
+        
+        textField.text = returnString[0] + " " + returnString[1]
+        
+        tableView.reloadData()
+        
+    }
+    
+    // MARK: Tools
+    
+    //Create an alert with a title, message, and dismiss button
+    func alert(alertTitle: String,alertMessage: String){
+        
+        let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: UIAlertControllerStyle.Alert)
+        
+        alertController.addAction(UIAlertAction(title: "dismiss", style: UIAlertActionStyle.Default,handler: nil))
+        
+        self.presentViewController(alertController, animated: true, completion: nil)
         
     }
     

        
    }
    
    //update the Parse database
    func updateDatabase(columnName: String,rowData: String){
        
        let SIObject = PFObject(className: "SI_Sign_in")
        SIObject[columnName] = rowData
        SIObject.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in self.updatedDatabaseTrue() }
        
    }
    
    func updatedDatabaseTrue() {
        updatedDatabase = true
    }
    
    //Create an alert with a title, message, and dismiss button
    func alert(alertTitle: String,alertMessage: String){
        
        let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: UIAlertControllerStyle.Alert)
        
        alertController.addAction(UIAlertAction(title: "dismiss", style: UIAlertActionStyle.Default,handler: nil))
        
        self.presentViewController(alertController, animated: true, completion: nil)
        
    }
    
    //So we can convert "Bob Smith" to "bob_smith"
    func addUnderscores(var inputString: String) -> String{
        
        var returnString = ""
        
        //Check if the string contains a date with forward slashes
        if inputString != "" {
            
            //split string by the spaces, then join it by underscore
            let newItemArr = inputString.componentsSeparatedByString(" ")
            inputString = newItemArr.joinWithSeparator("_")
            
            returnString = inputString.lowercaseString
            
        } else {
            
            alert("Invalid entry", alertMessage: "Empty input")
        
        }
        
        return returnString
        
    }
    
    //Saves the variables we need to remember
    func saveCoreVariables(){

        
    }

    //So we can convert "Bob Smith" to "bob_smith"
    func addUnderscores(var inputString: String) -> String{
        
        var returnString = ""
        
        let newItemArr = inputString.componentsSeparatedByString(" ")
        
        //If there were more than two words in the SI name input
        if newItemArr.count > 2 {
                
            alert("SI Name", alertMessage: "The SI name should only have one space")
                
        } else {
                
            inputString = newItemArr.joinWithSeparator("_")
                
            returnString = inputString.lowercaseString
                
        }
        
        return returnString
        
    }

