title: Scroll to a specific part of a UITextView in Swift
body: <p>In the Swift app I'm creating, the user can type some text into a text view and then search for a specific string within it, just like in Pages (and numerous others). </p>
  
  <p>I have the <code>index</code> of the character they are searching for as an Integer (i.e., they are on the third instance of "hello" in the massive text block they typed in, and I know that's the 779th letter of the text view) and I am trying to automatically scroll the text view to the string they're on, so that it pops out (like it would in Pages). </p>
  
  <p>I am trying to jump to the applicable string with this command:</p>
  
  <pre><code>self.textview.scrollRangeToVisible(NSMakeRange(index, 0))
  </code></pre>
  
  <p>but it never jumps to the right place (sometimes too far down, sometimes way too far up), often depending on screen size, so I know that <code>index</code> doesn't belong right there.</p>
  
  <p><strong>How can I correctly allow the user to jump to a specific string in a text view, by making the text view scroll to a certain character?</strong></p>