title: NSRange to Range<String.Index>
body: <p>How can I convert <code>NSRange</code> to <code>Range&lt;String.Index&gt;</code> in Swift? </p>
  
  <p>I want to use the following <code>UITextFieldDelegate</code> method:</p>
  
  <pre><code>    func textField(textField: UITextField!,
          shouldChangeCharactersInRange range: NSRange,
          replacementString string: String!) -&gt; Bool {
  
  textField.text.stringByReplacingCharactersInRange(???, withString: string)
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/bs7j6.png" alt="enter image description here"></p>