Dictionary objectForKey Crashing on Older Devices After Software Update

My apps were working fine and suddenly started crashing on older devices. I have iPhone 7 Plus to test and after updating it to 15.7.8, the installed apps which were working before started crashing. The specific code where they are crashing is

if([testStats objectForKey:TEST_STATS_ARRAY]) {
            statArray = [testStats objectForKey:TEST_STATS_ARRAY];
}
else {
            statArray = [[NSMutableArray alloc] init];
            [testStats setValue:statArray forKey:TEST_STATS_ARRAY];
}

[testStats objectForKey:TEST_STATS_ARRAY] this is where it crashes.

I am having to surround the code with try catch but such code exists all over the project and it is really difficult to make this change all over.

For newer phones this code is working fine, it goes into else part if the key is not found.

What does the crash look like? If you run your app from outside of Xcode, does it crash? And does that generate a crash report? If so, please post it here, using the process from Posting a Crash Report.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Dictionary objectForKey Crashing on Older Devices After Software Update
 
 
Q