I'm trying to establish the start and end positions of a text selection of a UITextField
instance, using its selectedTextRange
property (as gained from the UITextInput
protocol). However, I have no idea how to access the properties of the UITextPosition
objects that make up the start
and end
properties of selectedTextRange
.
Apple's docs on UITextPosition are woeful at this time, providing no methods or properties, though I know there are such properties in the object, because NSLogging one gives this:
<UITextPositionImpl: 0x6aaeb60>
<<WebVisiblePosition: 0x6aa40e0>(offset=5, context=([s|a], [u+0073|u+0061])>
In this example, the 'offset' is correct, and the context shows the characters either side of the selection point ('s' and 'a'), but I don't know how to access this nebulous WebVisiblePosition
class. So, in short, is there a way of retrieving the details I want using UITextPosition
objects from UITextField
?