I think you'll find what you're looking for in the documentation for UITextInputProtocol.
For some more high level information, check out Apple's Text, Web and Editing Guide, specifically in the section titled "A Guided Tour of a UITextInput Implementation". It discusses how you can create indexed positions in text, and ask touches what text position they've landed nearest.
Apple's references a sample projected called SimpleTextInput
, but I can't seem to find it. I'll keep looking.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…