arcade16 arcade16 - 4 months ago 12
iOS Question

Crash that only occurs via hockeyapp builds?

I am having an issue where a crash only occurs when the application is installed via HockeyApp, not via Xcode.

This is the report I get from HockeyApp:

*** Terminating app due to uncaught exception 'NSRangeException', reason: '-[__NSCFArray objectAtIndex:]: index (-1970199490 (or possibly larger)) beyond bounds (15)'
MainViewController.m, line 646

Which refers to this line:

for (int i; i < [resultsArray count]; i++) {
if ([[resultsArray[i] valueForKey:@"uniqueId"] isEqualToString:[[NSUserDefaults standardUserDefaults]
stringForKey:@"FbId"]]) {
resultsArray = resultsArray[i];
}
}


Any ideas why I would be getting a crash there when a build is installed via HockeyApp but not via Xcode? I've even tried building the app to a device using both development and distribution certs, but both work fine as long as the build isn't installed via HockeyApp.

Answer

I think the issue would be not initializing the value of the i in the for loop.

it should be for (int i=0;....

if it is not initialised, then the value of i would be unpredictable, it could be either null or it could be the value of its memory address.

if you didn't initialise it, then there will be infinite loop (if there is no crash) here as the value of i will be some random negative number -1970199490,

Also even if you do it from xcode, it results in the same behaviour.