(NSFetchedResultsController):无法读取缓存文件以更新商店信息时间戳 [英] (NSFetchedResultsController): couldn't read cache file to update store info timestamps

查看:203
本文介绍了(NSFetchedResultsController):无法读取缓存文件以更新商店信息时间戳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的项目升级到Xcode 8.现在,我得到这个错误日志与Xcode 8和iOS 10的组合。



将cacheName设置为nil下面的代码似乎解决了。

  NSFetchedResultsController * frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:self.managedObjectContext sectionNameKeyPath:NULL cacheName:@myCache]; 

我应该怎么做才能摆脱这个错误日志并在我的FRC中使用缓存?

解决方案

此错误不应被忽略,因为它可能导致应用程序崩溃。它涉及到一个iOS 10的文件描述符泄漏的bug。有关于openradar和Apple Bug Reporter的报告。



会发生什么:如果使用NSFetchedResultsController加载一个非nil cacheName的视图控制器,每次保存管理对象上下文,您将打开一个或多个指向fetchedResultsController的sectionInfo缓存文件的文件描述符。这意味着,如果保存上下文255次,您将达到可以在设备上打开的最大文件数,并且不会打开任何新资源,从而导致随后打开xib文件,图像,数据库等失败。 / p>

在已升级到iOS 10的设备上,已经在生产(使用xcode 7构建)的应用程序也会出现此问题。



一个临时解决方案是禁止使用nil作为cacheName的NSFetchedResultsController缓存:

  NSFetchedResultsController * frc = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext :self.managedObjectContext sectionNameKeyPath:NULL cacheName:nil]; 

显然,以这种方式,我们不能获得缓存的优势。
我希望苹果将修复错误asap。我将测试10.2 beta 1。



OPEN RADAR 28361550



EDIT
在iOS 10.2测试版1中,不会发生错误:现在)。


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).

这篇关于(NSFetchedResultsController):无法读取缓存文件以更新商店信息时间戳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆