title: Swift: Value of type 'string' has no member 'length'
body: <p>I Have Implement Some TextField Functionalities in my App so I used TextField Delegates but it show some error like "Value of type string has no member length" I don't know how to solve this please help me for fix this issue.</p>
  
  <p>Here I Give the Code of What I am trying.</p>
  
  <pre><code>func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -&gt; Bool {
      var oldLength: Int = textField.text!.characters.count
      var replacementLength: Int = string.characters.count
      var rangeLength: Int = range.length
      var newLength: Int = oldLength - rangeLength + replacementLength
      if textField.tag == 1 {
          if string.length &gt; 0 &amp;&amp; !NSScanner.scannerWithString(string).scanInt(nil) {  **------&gt;//Error was showed in this line.**
              return false
          }
          // This 'tabs' to next field when entering digits
          if newLength == 5 {
              if textField == txtOtp4 {
                  textField.resignFirstResponder()
              }
          }
          else if oldLength &gt; 0 &amp;&amp; newLength == 0 {
  
          }
  
          return newLength &lt;= 4
      }
      else {
          if newLength == 11 {
              if textField == txtPhoneNumber {
                  textField.resignFirstResponder()
              }
              return newLength &lt;= 10
          }
      }
      return true
      // This allows numeric text only, but also backspace for deletes
  }
  </code></pre>