xcode 核心数据关系故障

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1833423/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 18:59:13  来源:igfitidea点击:

Core Data Relationship Fault

xcodecore-datainterface-builderentity-relationship

提问by Kaji

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:

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

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

( <NSRelationshipDescription: 0x100143ed0>)、名称父级、isOptional 1、isTransient 0、实体族、renamingIdentifier 父级、验证谓词 ( )、警告 ( )、versionHashModifier ( null)、目标实体族、逆关系子族、minCount 0、maxCount 0 的关系错误(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?

我在网上做了一些阅读,这似乎与我建立了多对一关系的事实有关(因为一个父母可以有多个孩子,但我想限制每个孩子只有一个父母)。我一直在试图找出一种重构数据模型的方法,以免在需要以这种方式调用的事物上建立多对一的关系,但我在试图弄清楚时陷入困境如何跟踪孩子。关于解决问题的可能方法的任何想法?

回答by Adrian Sch?nig

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.

Core Data 中的错误不是错误,它只是意味着尚未从数据库中检索到您尝试访问的内容。如果你做了类似的事情,[fetchResults valueForKey:@"name"]它就会火,你应该得到你所期望的。你的关系模型应该没有问题。

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

顺便说一句,“minCount 0,maxCount 0”似乎很奇怪。这真的是你想要的吗?minCount of0和 maxCount of1应该更有意义。