Replace UITextViews text with attributed string
I have a UITextView and when the user is entering text into it, I want to format the text on the fly. Something like syntax highlighting... For that I'd like to use UITextView ... Everything works fine expect one problem: I take the text from the text view and make an NSAttributedString from of it. I make some edits to this attributed string and set it back as the textView.attributedText . This happens everytime the user types. So I have to remember the selectedTextRange before the edit to the attributedText and set it back afterwards so that the user can continue typing at the place he was