title: how to not allowed spaces in text field
body: <p>this is my code I want the user name not to have spaces and lowercase 
  example (wizkhalifa)</p>
  
  <pre><code>    func textField(_ textFieldToChange: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -&gt; Bool {
              if textFieldToChange == username {
                  let characterSetNotAllowed = CharacterSet.whitespaces
                  if let _ = string.rangeOfCharacter(from:NSCharacterSet.uppercaseLetters) {
                      return false
                  }
                  if let _ = string.rangeOfCharacter(from: characterSetNotAllowed, options: .caseInsensitive) {
                      return false
                  } else {
                      return true
                  }
  }
  
   if  UserNameField.text != nil, emailField.text != nil, passwordField.text != nil, rePassword.text != nil &amp;&amp; passwordField.text == rePassword.text {
                  Auth.auth().createUser(withEmail: emailField.text!, password: passwordField.text!, completion: { (user, error) in
                      if error != nil {
                          AlertController.showAlert(self, titel: "Error", message: " Fill all fields \nUser exists  ")
                          return
                      }
  </code></pre>