I am new to programming and could not find out how I might get the variable data back out of the function I created in swift. I tried returning the variable however I get an error in the compiler.
    class ViewController: UIViewController {
    @IBOutlet var textField: UITextField!
    var userName = String()
    @IBAction func returnPressed(_ sender: Any) {
        userName = textField.text! //user input will = userName
        print("return pressed inside textfield")
        print("User name set to \(userName)")
    self.view.endEditing(true) //hides keyboard
        return (userName)
    }
The function activates via the return being button pressed. The variable userName will then equal the users input within the text field.
The problem is that outside of this function, I can no longer call on the variable userName and receive the user input value that was stored earlier. And I cant seem to get the "return" to work like ive been reading.
 
     
     
     
    