iOS11 Crash in NSMutableRLEArray replaceObjectsInRange:withObject:length:: Out of bounds
Asked Answered
D

3

7

Our App Find a Foundation crash, only in iOS11. How to solve it ?

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:]
Demogorgon answered 26/10, 2017 at 3:15 Comment(6)
Put some code of replacement object action in NSMutableArray.Pastelist
Thank you . But we don't know what code trigger this crash . Our code use replaceObjectAtIndex so many place.Demogorgon
In XCode go to "Debug menu" then Move cursor on "Breakpoint" option. In which click on "Create Exception Breaskpoint". Then run again and follow same step that causes you crash. It will stuck at line where crash happen.Pastelist
We find this crash from Fabric Website. It collect our crash info from our App. We can not reproduce this crash by our testing.Demogorgon
I am having same issue, any update please?Sydney
Seeing the same crash when dragging a link in UITextView.Cervicitis
C
3

I could reproduce it in iOS 13.0 beta 4 with a sample app showing a UITextView with a special attributed string including a link. It crashes when tap-holding or dragging the link.

NSMutableAttributedString *aString = [[NSMutableAttributedString alloc] initWithString:@""];

NSTextAttachment *attachment = [[NSTextAttachment alloc] init];
attachment.image = [[UIImage imageNamed:@"weblink"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
attachment.bounds = CGRectMake(0, 0, 15, 15);
[aString appendAttributedString:[NSAttributedString attributedStringWithAttachment:attachment]];

[aString appendAttributedString:[[NSAttributedString alloc] initWithString:@"  More Information"]];
[aString addAttribute:NSLinkAttributeName value:[NSURL URLWithString:@"https://www.apple.com"] range:NSMakeRange(0, aString.length)];

self.textView.attributedText = aString;

Filed on  Feedback Assistant as FB6738178.

Cervicitis answered 19/7, 2019 at 13:49 Comment(2)
No, please file a bug, too. It's still open as of iOS 13.2 beta 4.Cervicitis
Still a bug at least in iOS 12.4-14.5. Removing the attachment from the link (so, not calling addAttribute:value:range:) prevents the long press crashWidely
R
0

I had the same issue when use the method of UITextInput

replaceRange:(UITextRange *)range withText:(NSString *)text;


I cannot find the best solution, but I fix the crash by avoiding using special characters

'

in the 2nd parameter of replaceRange method

ps:the issue only occurred in iOS 11

Renascent answered 24/4, 2018 at 9:47 Comment(0)
B
0

see if this can help you,the icon shouldn't be in the content of the hyperlink,otherwise,the system will get an out-of-bounds error

for example:

<link>this is a link.</icon></link>

this one will hit the error,but once you change the icon place like this:

<link>this is a link.</link></icon>

it will be fine.

Bahrain answered 9/5 at 7:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.