I have a ObjectA which has a one-to-many relationship with ObjectB. ObjectB has an inverse one-to-one with ObjectA. It all seems to go well until I realised that calling [objectA.objectBSet removeAllObjects]
breaks the inverse relationship of ObjectB's instances which where inside the Set. objectA.objectBSet
is just the NSMutableOrderedSet
of the objectBs which I (think) I get from the mogenerator tool (if that makes any difference).
Is this possible or I am doing something wrong? Can it be that simply removing an object from the set of its parent can influence the value of its inverse relationship automatically from CoreData?
Many Thanks
This is how it's supposed to work. If two relationships are inverses, then they must be consistent with each other for every object. If you tell an ObjectA
to remove all relationships to instances of ObjectB
, then those ObjectB
instances will also remove their relationship to that ObjectA
. That's how inverse relationships work. If the ObjectB
instances still claimed to be related to the ObjectA
instance, the inverse relationship would be in an inconsistent state.
If this isn't what you want for some reason, use relationships between ObjectA
and ObjectB
that are not inverses of each other.