I asked a developer (TwoLivesLeft, the creators of Codea) how they did syntax highlighting in their app. He replied :
@TD2 the Codea editor is implemented using a UITextView. The highlighting is done by overlaying subviews in the appropriate positions — usually UILabels. They are dequeued from a re-use pool, similar to the way UITableViewCells work. During scrolling, the lines requiring re-highlighting pull markers out of the pool and lines that have moved off screen dump their markers back into the pool.
Can anyone explain how I would get the x and y of a certain word?