title: Getting the cursor position of UITextField in ios
body: <p>I am trying to control the cursor position in the UITextField. Users cannot insert more than one character at a time into the middle of the text field. It moves it to the end of the textfield. So this post in SO: <a href="https://stackoverflow.com/questions/1500233/control-cursor-position-in-uitextfield">Control cursor position in UITextField</a> It solves my problem. But I need to know the current cursor position.</p>
  
  <p>My code looks like this:</p>
  
  <pre><code>- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
  {
     if (textField.tag == 201) 
     {
       [myclass selectTextForInput:textField atRange:NSMakeRange(idx, 0)];
     }
  }
  </code></pre>
  
  <p>It is giving me an error at idx. How do I find that?</p>