I get the following error message every time the application starts:
CoreData: FATAL ERROR: persistent cache of partition information does not match current configuration. You illegally mutated an NSFetchedResultsController fetch request, its predicate or its sort handle without disabling caching or using + deleteCacheWithName:
And here are the first ten points in the call stack:
*** First throw call stack: ( 0 CoreFoundation 0x04b835e4 __exceptionPreprocess + 180 1 libobjc.A.dylib 0x022c68b6 objc_exception_throw + 44 2 CoreData 0x020a1b41 -[NSFetchedResultsController performFetch:] + 913 3 Syllable 0x00036aa9 -[RootViewController fetchedResultsController] + 777 4 Syllable 0x0003772b -[RootViewController tableView:numberOfRowsInSection:] + 91 5 UIKit 0x00d1d240 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2510 6 UIKit 0x00d20b3d -[UITableViewRowData numberOfRows] + 98 7 UIKit 0x00ba94c2 -[UITableView noteNumberOfRowsChanged] + 120 8 UIKit 0x00ba8e6f -[UITableView reloadData] + 814 9 UIKit 0x10378ed1 -[UITableViewAccessibility(Accessibility) reloadData] + 50 10 UIKit 0x00bac8d3 -[UITableView _reloadDataIfNeeded] + 65
It gives a lot more, but it seems that all this is due to the first error that I posted. If they are useful, tell me and I will send them.
The problem is really strange. It seems he came out of nowhere. Even if I use git to revert to a previously working version, it still crashes, so I have no idea what caused it.
There is a solution to https://stackoverflow.com/a/167149/117111 ... but it is a bit unnerving. Will the cache remove cache from my application / make it slower? What consequences will this bring?
I am working on a new update for my application, and the priority is to make sure that this is not a failure for my existing / future users.
EDIT: I believe this caused the problem (although I have removed it since then and the problem has not been fixed):
I have the following code in my applicationDidFinishLaunching in my AppDelegate, which basically serves to create a special object in Core Data on the first launch of the application. Immediately after adding this problem, it seems that the problem arose, despite the fact that it soon deleted the code. Should I not manipulate the master data at this stage (is it too early)?
// If it the first time launching, create and add a sample article for an introduction if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"IsFirstTimeLaunching"] isEqualToString:@"YES"]) { NSManagedObjectContext *context = self.managedObjectContext; Article *article = [NSEntityDescription insertNewObjectForEntityForName:@"Article" inManagedObjectContext:context]; article.source = @"text"; article.body = @"some text"; article.timeStamp = [NSDate date]; NSError *error; [context save:&error]; [[NSUserDefaults standardUserDefaults] setObject:@"NO" forKey:@"IsFirstTimeLaunching"]; }
I also have this block in my AppDelegate, which has been there for quite some time, but to be honest, I'm not sure what it does for sure, I might just wrote it and forgot to finish it ...
- (void)applicationDidEnterBackground:(UIApplication *)application { NSManagedObjectContext *context = self.managedObjectContext; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Article" inManagedObjectContext:context]; NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:entity]; }