删除不会nulled直到保存:是真的吗? [英] Deleting won't nullify until save : is it true?

查看:113
本文介绍了删除不会nulled直到保存:是真的吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的情况:我在核心数据中有复杂的(24个实体,许多关系和许多有序到多个关系)模型。



现在让我们说,我有一个实体 PlayList 和实体 Song ,在 PlayList Song 的有序对多关系。这个关系有一个逆,并且都有一个 nullify 删除规则。



我注意到,当我删除属于 PlayList的 Song (让我们称为 gangnam c>,这首歌不会从关系中删除!我尝试用以下方法解决这个问题:




  • 我修复了与多对有序关系相关的Apple的错误, a href =https://github.com/CFKevinRef/KCOrderedAccessorFix =nofollow> KCOrderedAccessorFix 。顺便说一下,如果你使用其他解决方案,要小心,因为错误不仅是对于 addAnObject 部分,而且对于 removeAnObject 部分。 结果:好多了,但仍然无法工作:我的关系还指 gangnam :(

  • processPendingChanges 无效






  • 如果我保存我的上下文,


因此,我的问题是:



如果我想要 save > nullify 关系?
或者我缺少某些东西?



我试图重现bug一个较小的模型,但在这种情况下,调用 processPendingChanges 就足以 nullify 同样的问题/情况,我很高兴地知道,我不是唯一一个与核心数据;)

战斗 =h2_lin>解决方案

由于一个原因,实体的图形是不一致的( CoreData 的一个错误)它们的逆不被适当地保持)。所以,它拒绝删除对象。如果我保存,它首先使图形一致,然后可以删除该对象。


My situation : I have complex (24 entities, many relationships and many ordered to-many relationships) model in Core Data.

Now let's say, I have an entity PlayList and an entity Song, and in PlayList an ordered to-many relationship to Song. This relationship has an inverse, and both have a nullify delete-rule.

I have remarked that when I delete a Song (let's call it gangnam) that belongs to a PlayList, this song is not removed from the relationship !! I tried to fix this with the following :

  • I fixed the Apple's bug related to the to-many ordered relationships, using the excellent : KCOrderedAccessorFix. By the way, be careful if you use other solutions, because the bug is not only for the addAnObject part but also for the removeAnObject part. Result : much better but still not working : my relationship still refers to gangnam :(
  • I tried : processPendingChanges : not working.

Now,

  • If I save my context, the Song gangnam is removed.

So, my question is :

Do I have to save my context if I want to nullify the relationships ? Or am I missing something ?

I tried to reproduce the "bug" with a smaller model, but in this case, calling processPendingChanges is enough to nullify the relationship. So, if anyone has encountered the same problem/situation, I would be happy to know that I am not the only one to fight with Core Data ;)

解决方案

For a reason, the graph of the entities was not coherent (some bug of CoreData I guess, the relations and their inverse are not properly maintained). So, it refuses to delete the object. If I save, it first makes the graph coherent and then it is possible to remove the object.

这篇关于删除不会nulled直到保存:是真的吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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