I have 5 levels (or even more) linked realm objects in my code. Projects, including sections, including tasks, including attachments and ...
我的代码中有5个级别(甚至更多)链接的域对象。项目,包括部分,包括任务,包括附件和......
I've found in some other questions that I should get the linking objects, like this:
我在其他一些问题中发现我应该得到链接对象,如下所示:
private let sections = LinkingObjects(fromType: Section.self, property: "tasks") var section:Section? { return sections.first }
private let sections = LinkingObjects(fromType:Section.self,property:“tasks”)var section:Section? {return sections.first}
This code solves the problem for the first parent. But for the grand parents(!) this return nil again. So this is not the ultimate solution.
此代码解决了第一个父代的问题。但对于盛大的父母(!),这又回来了。所以这不是最终的解决方案。
Any better ideas?
还有更好的想法?
1 个解决方案
#1
1
Turns out, all the objects should have primary keys in order to maintain relationships. Or they will lose the relationship after updates.
事实证明,所有对象都应该有主键以维持关系。或者他们将在更新后失去关系。
One of my objects in the chain, did not have a primary key.
链中的一个对象没有主键。
#1
1
Turns out, all the objects should have primary keys in order to maintain relationships. Or they will lose the relationship after updates.
事实证明,所有对象都应该有主键以维持关系。或者他们将在更新后失去关系。
One of my objects in the chain, did not have a primary key.
链中的一个对象没有主键。