title: How to move to the next UITextField automatically in Swift
body: <p>I have 2 textFields with NumberPad keyboard type</p>
  
  <pre><code>@IBOutlet weak var ourTextField: UITextField!
  @IBOutlet weak var forThemTextField: UITextField!
  </code></pre>
  
  <p>and I want to automatically move to the other textfield (from ourTextField to forThemTextField) after entering two numbers inside the ourTextField then after going to the other textfield (forThemTextField) and entering 2 numbers I want the keyboard hide automatically </p>
  
  <p>I have added a condition to only accept two numbers in my textFields by this code :</p>
  
  <pre><code>func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -&gt; Bool {
      let lengthsDictionary = [ourTextField : 2, forThemTextField: 2]
      guard let length = lengthsDictionary[textField] else {
          return true
      }
      let currentCharacterCount = textField.text?.count ?? 0
      if (range.length + range.location &gt; currentCharacterCount){
          return false
      }
      let newLength = currentCharacterCount + string.count - range.length
  
      return newLength &lt;= length
  }
  </code></pre>