Reputation: 31642
I'm getting an interesting new error with iOS 4:
-[NSCFString substringWithRange:]: Invalid range {11, 4294967295}; this will become an exception for apps linked on SnowLeopard. Warning shown once per app execution.
The error is caused by a snippet of code I got from a blog post that helps Title Case a string, and it's not going to be hard to fix, but I haven't seen this mentioned anywhere else, and I'm assuming Apple wants people to stop using the magic 4294967295 number.
Does anyone know about the history / background of this change?
EDIT: Source for the Title Case code is located at: http://vengefulcow.com/titlecase/ It's the objective-c port (obviously). Line 116 is the offender. Clearly it's a problem only under some specific condition. I'm still tracking it down.
Upvotes: 0
Views: 897
Reputation: 162712
Unsigned 4294967295 is the same as the signed uint32_t value for -1. I've seen problems where a 32 bit app archived -1 and a 64 bit app unarchived it as a Big Ass Length (terribly fun when it was Xcode calling malloc(4294967295)
during the 64-bit bring-up).
The Cocoa frameworks are detecting that you passed in a range where the length is longer than the string itself. Warning now, with truncated results, but it'll be a hard error in the future.
(In some cases, NSNotFound can cause these kinds of issues).
Upvotes: 1