you code is correct.it means the offset into a string's code units for this index.
for example:
var textString = "niaddjkdskjdsjdsk"
let location = textString.range(of: "dd")?.lowerBound.utf16Offset(in: textString)
as we know, the bound is (3,_),so the utf16Offset is 3.
Before Swift 4.2,we use encodedOffset
,now it replace by utf16Offset, they are same behavior
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…