Possible Duplicate:
Does every Core Data Relationship have to have an Inverse?
I have the following entities with the relationships:
A CombinedSH
must have a Subject
and a StudyHour
.
A Subject
must NOT have a CombinedSH
.
A StudyHour
must NOT have a CombinedSH
.
In my app, it does not make sense that a Subject
/ a StudyHour
will have a CombinedSH
.
The problem is that Xcode gives me the following warnings:
warning: Misconfigured Property: CombinedSH.studyHour should have an inverse.
warning: Misconfigured Property: CombinedSH.subject should have an inverse.
So Xcode says that there should be an inverse - but in my app it doesn't make sense. What should I do?
You can define the inverse relationship from Subject
to CombinedSH
and mark it as "optional". Then a "Subject" need not have a "CombinedSH".
Doing so makes Xcode happy, but has also another advantage. Assume you have objects
CombinedSH *csh1;
Subject *s1;
and
csh1.subject = s1;
What happens, if s1
is deleted? Without inverse relationship, csh1.subject
would point to some deleted object.
But if you define the inverse relationship, and set the "Delete Rule" of that relationship to "Nullify", then deleting s1
automatically sets
csh1.subject = nil
and therefore subject
cannot point to a deleted object anymore.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With