How can I break on this error in Xcode?

I'm getting this error in the console:

*** -[__NSCFString substringWithRange:]: Range {18446744073709551615, 1} out of bounds; string length 43. This will become an exception for apps linked after 10.10 and iOS 8. Warning shown once per app execution.

Great! So I created a category on NSString for _substringWithRange and _***_stringByReplacingCharactersInRange that call the original method (note undescore), then changed every usage in my app to use my own method, in which I test for location == NSNotFound.

Nothing.

So I swizzled both methods, and again tested for NSNotFound, and again nothing.

What can I do to break when this error happens?

Thanks David

Replies

On which version of iOS do you test ? Is it Swift or objC code ?

If beyond iOS 8, you should see a crash. Do you get it ?

Do you use NSMakeRange ? If so, look here: https://stackoverflow.com/questions/11131472/substring-with-range-out-of-bounds

Can't you find which String is of length 43 ?

You have probably searched and found that:

https://stackoverflow.com/questions/24462014/substringwithrange-out-of-bounds-what-am-i-missing

and

https://github.com/realm/SwiftLint/issues/3761

  • I'm on latest iOS 15.5. Building on latest Xcode. Trying to test out some other code in a really large mostly Objective-C app. An no, I don't get a crash just the message. Obviously something is generating it.

    Why would me making ranges have anything todo with it? I'm bottlenecking it at the bottom of the app.

    The string length varies from run to run. Even it if was always 43, then what would I do? Bottle neck as I have and test for string length == 43? I'm already testing location.

Add a Comment