NSMutableAttributedStrings - objectAtIndex:effectiveRange:: Out of bounds

后端 未结 2 1956

I\'m trying to add some fancy text to a label, but I\'ve run into some problems with the NSMutableAttributedString class. I was trying to achieve four this: 1. Change font,

相关标签:
2条回答
  • 2020-12-11 02:51

    NSRange has two values, the start index and the length of the range.

    So if you're starting at index 6 and going length characters after that you're going past the end of the string, what you want is:

    NSRange worldRange = NSMakeRange(6, length - 6);
    
    0 讨论(0)
  • 2020-12-11 03:05

    Your length is too long on worldRange. NSMakeRange takes two arguments, the start point and the length, not the start point and the end point. That's probably why you are getting confused about both problems.

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