title: storing user-entered data from UITextField in String variable
body: <p>I'm having problems with the below code storing the right characters from user:  If the user enters "there" it stores "ther".</p>
  
  <pre><code>func textField(_ textField: UITextField,
                 shouldChangeCharactersIn range: NSRange,
                 replacementString string: String)
      -&gt; Bool
  {
      let text: String = nameInputText.text!
      //print(text) //this prints My text
      model.validateName(nametext: text)
      print(text)
      return true
  }
  </code></pre>
  
  <p>I also have these functions for my keyboard hiding:</p>
  
  <pre><code> override func touchesBegan(_ touches: Set&lt;UITouch&gt;, with event: UIEvent?) {
      self.view.endEditing(true)
  }
  
  func textFieldShouldReturn(_ textField: UITextField) -&gt; Bool {
      nameInputText.resignFirstResponder()
  
      return (true)
  }
  </code></pre>