My task boils down to extracting the range of characters in a given line of a multiline UILabel. These lines are the lines that appear where the UILabel breaks to fit to width: in other words, not separated by hard line breaks. This seem to rule out lineRangeForRange:. Or am I wrong?
Context : I have an iPhone game where a user taps UILabel text to position a kind of cursor. This is a bit like the magnifying glass insertion point in NSTextField. I need to be able to translate a user tap to a particular character in a multi-line label and draw the cursor there: then, when the user choose a letter from a set of tiles in openGl, I insert the chosen character there.
I can easily translate the user tap to the line tapped on, then create a string that I keep adding characters to, until I have all the preceding lines. I would then start a new NSSTring based on what I discover is the first character of the line of interest, and add to it until I get to the closest approximation of the tap location. But this seems like a bit of a hack -- if I can just say "Give me line n of this chunk of text constrained to this width, a lot of the work will be simplified.
Or is there another known technique to translate a tapped location to a physical coordinate?