Out of bounds Problem with attributedSubstringFromRange

前端 未结 1 2025
死守一世寂寞
死守一世寂寞 2021-01-16 17:48

I have a NSMutableAttributedString, I need to take substring from it.I use the following code to take substring,

startIndex and endIndex are two long variables.

相关标签:
1条回答
  • 2021-01-16 18:14

    This isn't how NSRange works. It is location (startIndex for you) and length. Hence the second goes from 10958 to 10958 + 12961 = 23919, which is out of bounds.

    0 讨论(0)
提交回复
热议问题