“核心数据不能实现故障”对于未删除的对象 [英] "Core Data could not fulfill a fault" for objects that were not deleted

查看:153
本文介绍了“核心数据不能实现故障”对于未删除的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于应用程式的最近更新,我看到许多崩溃日志,其中包含核心数据无法完成故障的错误。但在应用程序(启动或其他地方)的任何地方,我删除的故障不能实现的对象,也不会被级联删除。这个错误怎么会发生?

For a recent update to an app, I am seeing many crash logs with the error that core data could not fulfill a fault. But nowhere in the app (startup, or elsewhere) did I delete the objects whose faults cannot be fulfilled, nor would they have been cascade deleted. How else can this error be happening? And is there a way to catch it and fix it within the live app?

如果你添加了但是没有正确地保存对象,还有可能吗?

Could it also be if you added but did not properly save the object yet?

推荐答案

这可能是因为没有正确储存的物件导致此行为。

It is possible that an object that was not "properly" saved to cause this behaviour.

一种方法是:


  • 在子上下文中插入对象

  • 获取该对象的永久ID

  • 保存到父级背景中
    b $ b
  • 在父级上下文中获取对象

  • 刷新父级上下文中的对象

  • 访问父上下文中的对象(履行该对象的错误)

  • Insert an object in a child context
  • obtain a permanent ID for that object
  • save to the parent context
  • obtain the object in the parent context
  • refresh the object in the parent context
  • access the object in the parent context (fulfil a fault for that object)

编辑:

在单一环境架构中达到这个状态的另一种方法是:

Another way to reach this state in a single context architecture is:


  • 插入对象

  • 获取对象的永久ID

  • 刷新对象

  • 尝试访问对象(触发对象的错误)

  • Insert an object
  • obtain a permanent id for the object
  • refresh the object
  • try and access the object (trigger a fault on the object)

刷新可能是抓取的结果结果控制器通过数据分页,而不一定是应用程序中的可见。

the refresh might be a result of a fetched results controller paging through the data and not necessarily something "visible" in your application.

此外,还有一个CoreData错误您可以在父子上下文体系结构中捕获此异常,但您可以尝试...

In addition, there is a CoreData "bug" that not always allows you to catch this exception in a parent-child context architecture, but you can try ...

但是,如果这是您遇到的情况,不是您的应用程序所需的行为。您将丢失添加到商店的新数据。

However, if this is the scenario you encounter, this is not a desired behaviour for your application. you are loosing the new data added to the store.

这篇关于“核心数据不能实现故障”对于未删除的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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