NSMutableRLEArray 中的 iOS11 崩溃 replaceObjectsInRange:withObject:length:: Out of bounds

Ben*_*hen 7 crash foundation ios11

我们的 App Find a Foundation 崩溃,仅在 iOS11 中。如何解决?

Fatal Exception: NSRangeException
NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds

0  CoreFoundation                 0x184f8bd38 __exceptionPreprocess
1  libobjc.A.dylib                0x1844a0528 objc_exception_throw
2  CoreFoundation                 0x184f8bc80 -[NSException initWithCoder:]
3  Foundation                     0x18587c168 -[NSMutableRLEArray replaceObjectsInRange:withObject:length:]
4  Foundation                     0x18588262c -[NSConcreteMutableAttributedString replaceCharactersInRange:withAttributedString:]
5  CoreFoundation                 0x184e65bec -[__NSArrayM enumerateObjectsWithOptions:usingBlock:]
6  UIKit                          0x18ec677b8 -[UILayoutManagerBasedDraggableGeometry draggableObjectsForTextRange:]
Run Code Online (Sandbox Code Playgroud)

Kar*_*ang 0

使用 UITextInput 方法时我遇到了同样的问题

替换范围:(UITextRange *)范围 withText:(NSString *)文本;


我找不到最佳解决方案,但我通过避免使用特殊字符来修复崩溃

'

在replaceRange方法的第二个参数中

ps:该问题仅出现在iOS 11中