Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ArtOfWarfare

macrumors G3
Original poster
Nov 26, 2007
9,706
6,289
Whenever I type in a text view in my application, the cursor jumps from wherever it was (and should be,) to the end of the text.

The line in the for loop seems to be the issue. If I comment out just that, it runs perfectly fine.
Code:
- (void)textViewDidChange:(UITextView *)textView
{
    for (NSString *key in shortcuts)
    {
        typeView.text = [typeView.text stringByReplacingOccurrencesOfString:key withString:[shortcuts objectForKey:key]];
    }
}
Does anyone have a simple solution for this (IE, there's a method already in the SDK that I'm overlooking that'll do it for me,) or am I going to have to determine the cursors position just before the loop and then put it back where it was afterwards myself?

Edit: I've added an if before the line to make sure there's actually something to replace beforehand, now.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.