How to convert character index from layoutManager to String scale in swift?
this is the code I'm using:
let touchPoint: CGPoint = gesture.locationOfTouch(0, inView: self.definitionLabel)
let index = layoutManager.characterIndexForPoint(touchPoint, inTextContainer: textContainer, fractionOfDistanceBetweenInsertionPoints: nil)
The index returned from the
NSLayoutManager is "
i.e. it is the number of UTF-16 code units from the start of the string
to the character at the given point. (So
ò actually counts as
one, but Emojis