title: UITextPosition to Int
body: <p>I have a UISearchBar on which I am trying to set a cursor position. I am using UITectField delegates as I couldn't find anything direct for UISearchBar. Below is the code I am using:</p>
  
  <pre><code>  UITextField *textField = [searchBar valueForKey: @"_searchField"];
    // Get current selected range , this example assumes is an insertion point or empty selection
    UITextRange *selectedRange = [textField selectedTextRange];
    // Construct a new range using the object that adopts the UITextInput, our textfield
    UITextRange *newRange = [textField textRangeFromPosition:selectedRange.start toPosition:selectedRange.end];
  </code></pre>
  
  <p><em><strong>Question</em></strong> is in the 'newRange' object for 'toPosition' I want to have something like selectedRange.end-1; as I want the cursor to be on second last position.</p>
  
  <p>How do I set the cursor to second last position?</p>