核心数据-如何禁用故障机制 [英] Core Data - How to disable faulting mechanism

查看:64
本文介绍了核心数据-如何禁用故障机制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法告诉Core Data禁用其内存管理?我的视图中有NSManagedObjects,很长一段时间都没有保存到上下文中。被管理对象在表格视图中。用户将首先看到该视图,然后导航到另一个视图,并在此花费大量时间,然后返回表格视图。我收到此异常: NSObjectInaccessibleException-CoreData无法实现故障

Is there any way to tell Core Data to disable its memory management? I have NSManagedObjects in a view that don't get saved to a context for a very long time. The managed objects are in a table view. The user will see that view first, then navigate away to another view, spending lots of time there before returning to the table view. I am getting this exception: "NSObjectInaccessibleException - CoreData could not fulfill a fault"

推荐答案

Core Data故障实现错误通常意味着您正在处理的对象已发生故障,而另一个线程已删除其中一个子对象并提交给持久性存储。因此,当原始线程返回执行该故障时,就不再存在任何内容。

A Core Data fault fulfillment error usually means that you are holding on to an object that has been faulted and another thread has deleted one of the children objects and committed to the persistent store. So when the original thread goes back to fulfill the fault, there isn't anything there anymore.

您可以做的一件事就是让您的其他视图侦听NSManagedObjectContextDidSave和NSManagedObjectContextWillSave对更改进行响应(即重新加载数据),因此您不会在缓存中发现不良对象。

One of the things you can do is have your other views listen to NSManagedObjectContextDidSave and NSManagedObjectContextWillSave to react to the change as it is occurring (i.e. reload the data fresh), so you don't wind up with bad objects in the cache.

这篇关于核心数据-如何禁用故障机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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