I have a textView which is displaying a string. I also have an array which keeps track of where every line begins, it stores the "start index" or NSRange.location for every line.
However, when text is inserted on one line, the start indexes of every line afterwards change. So I'm doing this:
//i = the linenumber of the modified row
// self.lineStartIndexes = NSMutableArray
for (int j = i+1; j < self.lineStartIndexes.count; j++) {
_lineStartIndexes[j] = @([(NSNumber *)[self.lineStartIndexes objectAtIndex:j] intValue]+text.length);
}
This takes 12ms on a large text file, and it feels like it could go a lot faster without all NSNumber
-conversions. I have thought about using C arrays, but I don't know the size of the array and everything became very complicated to me. What should I do to optimize this?