核心数据关系错误(不是延迟加载)。关系消失
我有一个核心数据数据库,其中(目前)有 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我正确理解问题的描述,则可能是由于没有从 CompetingProduct 到 Product 设置相互关系造成的。
如果关系是:
... 而不是:
... 那么您将能够从产品开始找到竞争产品,但您将能够通过从竞争产品开始找到产品。
如果这不是问题,那么听起来您可能有多个上下文,并且没有保存所做更改的上下文。
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:
...and not:
... 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.