Reputation: 2259
I am facing an issue with coredata relationship. Here is my problem scenario step wise
Problem : When I print the members of "Group2" from relationship of "GroupTable" all 3 records are printed, but When I print the members of "Group1" from relationship of "GroupTable", there are no records. Similarly if I keep on creating new groups with the same 3 contacts the records printed only in the last group.
Can anyone help me out in this or suggest any approach.
Upvotes: 0
Views: 40
Reputation: 21536
This is a consequence of defining the relationship from ContactTable
to GroupTable
as "to-one": each Contact
can be related to only one Group
. Hence when you save the 3 Contact
s to "Group2", CoreData automatically removes them from "Group1".
If you want instances of Contact
to belong to both "Group1" and "Group2", then you must define the relationship from ContactTable
to GroupTable
as "to-many".
Upvotes: 1