CoreData:“悬停对无效对象的引用”。错误 [英] CoreData: "Dangling reference to an invalid object." error

查看:156
本文介绍了CoreData:“悬停对无效对象的引用”。错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Cocoa-Touch应用程序,它使用CoreData和一些由XCode模型编辑器生成的NSPersistentObject子类。



我注意到,当保存上下文时我得到一个错误,作为用户信息的以下部分:

 (gdb)po ui {
悬挂对无效对象的引用。 =< null> ;;
NSAffectedObjectsErrorKey =< dump#1 of someObject> ;;
NSLocalizedDescription =操作无法完成。(Cocoa错误1550.);
NSValidationErrorKey =< someKey指向someObject#1> ;;
NSValidationErrorObject =< dump#2 of someOtherObject指向转储#1对象> ;;
NSValidationErrorValue = {< list of someMoreObjects> };
}

用户信息字典中有其他键。

$



NSValidationErrorObject

code>是一个具有 NSSet 的对象,它包含在 NSAffectedObjectsErrorKey NSValidationErrorValue 。但是所有这些对象都是有效的。



此外,这种情况是随机发生的,有时候会发生,有时候不会发生,有时候列表转储在 NSValidationErrorValue 更长,有时更短。



我没有线索为什么会发生这种情况,或者错误是什么。有谁知道发生了什么?

解决方案

这个错误通常是因为当一个对象离开时经常设置不正确的关系没有必要的相互关系。对象是悬挂,因为对象图表示它应该在一个关系,但它只是悬挂在未连接到任何其他对象的空间。对象仍然有效,因为它是内部一致的,但它不在图中的有效位置。


I'm working on a Cocoa-Touch app, it uses CoreData and has some NSPersistentObject subclasses generated by the XCode model editor.

I've noticed that recently, when saving the context I get an error which has as user info the following part:

(gdb) po ui {
    "Dangling reference to an invalid object." = <null>;
    NSAffectedObjectsErrorKey = <dump #1 of someObject>;
    NSLocalizedDescription = "Operation could not be completed. (Cocoa error 1550.)";
    NSValidationErrorKey = <someKey pointing to someObject #1>;
    NSValidationErrorObject = <dump #2 of someOtherObject which points to the dump #1 object>;
    NSValidationErrorValue = { <list of someMoreObjects> };
}

There are on other keys in the user info dictionary.

All the dumps I get are valid objects, I've verified them all.

NSValidationErrorObject is an object which has an NSSet which contains objects of types dumped in NSAffectedObjectsErrorKey and NSValidationErrorValue. But all these objects are valid.

Furthermore, this happens randomly, sometimes it happens, sometimes not, and sometimes the list dumped in NSValidationErrorValue is longer, sometimes shorter.

I have no clue why this is happening, or what exactly the error is. Does anyone know what's going on? Any ideas what might cause this bizarre error?

解决方案

This error usually arises because a relationship is set improperly often when an object is left without a necessary reciprocal relationship. The object is "dangling" because the object graph says it should be in a relationship but it is just hanging off in space unconnected to any other object. The object is still valid in the sense that it is internal consistent but it's not in a valid place in the graph.

这篇关于CoreData:“悬停对无效对象的引用”。错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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