核心数据关系故障 [英] Core Data Relationship Fault

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

问题描述

在Core Data中跟踪家庭关系(1个父实体和2种类型的儿童,其中之一是递归),尝试在Interface Builder中创建一个下拉菜单,其中列出了父实体的名称,以便用户可以选择一个关联作为正在编辑的条目的父级。我有绑定所有设置,但当它运行时,它会在菜单的第一个插槽中产生以下错误文本:

Tracking a familial relationship in Core Data (1 parent entity + 2 types of children, one of which is recursive), trying to create a drop-menu in Interface Builder that lists the names of the parent entities so that the user can choose one to associate as the parent of the entry being edited. I've got the bindings all set, but when it runs it produces the following error text in the first slot of the menu:


关系(< NSRelationshipDescription:0x100143ed0> ),name parent,isOptional 1,isTransient 0,entity Family,renamingIdentifier parent,validation predicate(
),警告(
),versionHashModifier( null destination entity Family,inverseRelationship subFamilies,minCount 0,maxCount 0 on 0x10025c850

Relationship fault for (<NSRelationshipDescription: 0x100143ed0>), name parent, isOptional 1, isTransient 0, entity Family, renamingIdentifier parent, validation predicates ( ), warnings ( ), versionHashModifier (null), destination entity Family, inverseRelationship subFamilies, minCount 0, maxCount 0 on 0x10025c850

我在网上做了一些阅读,它似乎与一个事实,我有一个多对一的关系设置(因为一个父可以有多个孩子,但我想限制每个孩子只有一个父)。我一直在试图找出一种方法来重组数据模型,而不是在需要以这种方式调用的东西上建立一个多对一的关系,但我正在卡住试图找出如何跟踪孩子。关于解决问题的可能方法的任何想法?

I've done a little bit of reading around online, and it appears to have to do with the fact that I've got a many-to-one relationship set up (as one parent can have multiple children, but I want to limit each child to only one parent). I've been trying to figure out a way to restructure the data model to not put a many-to-one relationship on something that'll need to be called up in such a fashion, but I'm getting stuck trying to figure out how to track the children. Any ideas on possible methods of resolving the issue?

推荐答案

Core Data中的错误不是错误,您尝试访问的内容尚未从数据库检索。如果你做类似 [fetchResults valueForKey:@name] ,它会触发,你应该得到你期望的。这不应该是你的关系模型的问题。

A fault in Core Data is not an error, it just means that the what you are trying to access hasn't been retrieved from the database yet. If you do something like [fetchResults valueForKey:@"name"] it will fire and you should get what you expect. It shouldn't be a problem with your relationship model.

顺便说一句,minCount 0,maxCount 0似乎很奇怪。这是真的你想要什么? minCount 0 和maxCount 1 应该更有意义。

By the way, "minCount 0, maxCount 0" seems weird. Is that really what you want? minCount of 0 and maxCount of 1 should make more sense.

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

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