I've been seeing a lot of crash reports on iOS 15 for code that has been in place a long time. The crash report indicates this is happening during the call to saveAppData
while trying to persist the state of the users tab order. There is a More Controller in the mix but this was working for literally years.
I've been staring at this for days and can't find anything obvious. I am wondering if something changed with iOS 15 which is when this issue started . This is the relevant code:
-(void)saveAppData
{
// Save Current Tab Order to Users Prefs
NSMutableArray *savedOrder = [NSMutableArray arrayWithCapacity:TAB_BAR_NUMBER_OF_ITEMS];
NSArray *tabOrderToSave = _tabBarController.viewControllers;
for(UIViewController *aViewController in tabOrderToSave) {
[savedOrder addObject:@(aViewController.tabBarItem.tag)];
}
[userSettings setObject:savedOrder forKey:SavedTabOrderKey];
// Save the TAG of selected TabBarItem
[userSettings setObject:@(_tabBarController.tabBar.selectedItem.tag) forKey:SavedTabLastViewedKey];
[userSettings synchronize];
}
-(void)applicationDidEnterBackground:(UIApplication *)application
{
NSLog(@"**** Entering Background Saving Data");
[self saveAppData];
[self.coreDataUtil saveMOC];
}
and here is the crash report. Any assistance on observations are most welcome. Thanks.