I'm trying to create a text view in my app. It simply highlights the syntax and displays the highlighted text in a UITextView via AttributedText. Here's the code:
NSMutableString *ms = [[NSMutableString alloc] initWithString:self.text];
[ms replaceCharactersInRange:range withString:text];
self.attributedText = [syntaxHighlighter highlight:ms inRange:[self visibleRangeOfText]];
[self setSelectedRange:NSMakeRange(range.location + text.length, 0)];
The problem is for large texts, it has to replace the whole text in 3rd line. Is there a way to just replace a part of text without replacing the whole content?