I upgraded my project to Xcode 8. Now, I'm getting this error log with Xcode 8 and iOS 10 combination.
Setting the cacheName to nil in the below code seems fix it.
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:NULL cacheName:@"myCache"];
What should I do to get rid of this error log and use cache in my FRC?
This error should not be ignored because it can cause app crash. It is related to an iOS 10 bug of file descriptor leaks. There are reports on openradar and Apple Bug Reporter.
What happen: if you load a view controller using NSFetchedResultsController with a non-nil cacheName, every time you save the managed object context you will open one or more file descriptors pointing to the sectionInfo cache file of the fetchedResultsController. This means that if you save context 255 times, you will reach the maximum number of files that can be opened on devices and no new resources may be opened, causing any subsequent opening of xib files, images, database, etc. to fail.
The problem occurs also for apps already on production (built with xcode 7) on devices upgraded to iOS 10.
A temporary solution is disabling NSFetchedResultsController caching with nil as cacheName:
NSFetchedResultsController *frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:NULL cacheName:nil];
Obviously in this way we can't get advantage of caching. I hope Apple will fix the bug asap. I am going to test against 10.2 beta 1.
OPEN RADAR 28361550
EDIT On iOS 10.2 beta 1 the bug does not occur: it has been solved (for now).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With