我试着这样做:
[mutableAttributedString enumerateAttribute:NSFontAttributeName inRange:underlineRange options:NSAttributedStringEnumerationLongestEffectiveRangeNotRequired usingBlock:^(id value, NSRange range, BOOL * _Nonnull stop) {
....
然而
underlineRange
可以通过某种方式进行操纵,使其脱离
mutableAttributedString
范围。在这种情况下,它最终会导致异常。
处理这个案子最好的办法是什么?我找不到任何nsattributestring方法可以让您验证一个范围对于给定的属性字符串是否有效。