核心数据关系错误(不是延迟加载)。关系消失

发布于 2024-09-28 01:09:59 字数 586 浏览 5 评论 0原文

我有一个核心数据数据库,其中(目前)有 2 个实体 Product 和 CompetingProduct,CompetingProduct 关系设置为多个产品。

我创建了 2 个模拟产品和 2 个模拟竞争产品,并设置它们之间的关系.. 一切都有效文件.. 保存到数据库,还有 NSlog,“po”它们.. 一切都很好。

现在..当我重新启动应用程序或我从不同视图请求竞争产品类型的所有对象时..我得到关系竞争产品和产品之间的关系出现错误(尽管我之前添加了它们并保存了)

我知道关于数据核心的延迟加载,但情况并非如此,因为当我尝试 [NSSet allObjects] (也 po ,nslog - 无)它返回 0 个通常应该获取对象的对象。

注意:在我调用 saveChanges 后,所有事情都会正常工作

,绝对任何帮助都会感激赢得我的尊重 当然还有几杯啤酒

谢谢!

I have a core data database which has (for now) 2 entities Product and CompetingProduct, CompetingProduct relation is set to-many with products.

I create 2 mock Products and 2 mock Competing products and set relation between them .. everything works files.. Saved to database, also NSlog, "po" them.. all is good.

Now.. when i restart the app or i request all objects of competing product type from a different view.. i get Relation fault for the relation between Competing Product and Products (although i added them earlier, and saved)

I know that about the lazy loading of data core but here is not the case because when i try [NSSet allObjects] (also po, nslog - nothing) it returns 0 objects which normally should get objects.

Note: Immediately after i call saveChanges - all things work

Absolutely ANY help will be greatly appreciated and win you my respect and of course a couple of beers

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

愿与i 2024-10-05 01:09:59

如果我正确理解问题的描述,则可能是由于没有从 CompetingProduct 到 Product 设置相互关系造成的。

如果关系是:

Product-->CompetingProduct

... 而不是:

Product<-->CompetingProduct

... 那么您将能够从产品开始找到竞争产品,但您将能够通过从竞争产品开始找到产品。

如果这不是问题,那么听起来您可能有多个上下文,并且没有保存所做更改的上下文。

If I understand the description of the problem correctly, it could be caused by not having a recipocal relationship set from CompetingProduct to Product.

If the relationship is:

Product-->CompetingProduct

...and not:

Product<-->CompetingProduct

... then you will be able to find CompetingProducts starting with a Product but you will be able to find a Product by starting with a CompetingProduct.

If this is not the problem then it sounds like you may have multiple context and are not saving the one the changes are made in.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文