0

I have two Entities: Group and Member:

Entity name: Group
Relationships:
Member (inverse:Group) (to-many relationship)

Entity name: Member
Relationships:
Group (inverse:Member)

So a Group can have several members, and the same Member can belong to several Groups, but the Members don't know which groups they belong to (there is no inverse)

But something strange is happening. If I add a Member to GroupA, he is added successfully. If I add the same member to GroupB, he is removed from GroupA and added to GroupB. Any ideas why this is happening? Have I set up my model correctly?

Edit: Set up inverse relationship, but this didn't fix the issue.

Snowman
  • 29,431
  • 43
  • 165
  • 290

1 Answers1

2

I'm not sure if this is the cause of what you're seeing, but it's a very, very, very good idea to always have an inverse relationship set up, even if you don't use it. See https://stackoverflow.com/a/764572/144755

Edit: I would suggest adding a Groups to-many relationship from the Member entity. It sounds like what is happening is that CoreData is guessing that the relationship from Member to Group is to-one

Community
  • 1
  • 1
oltman
  • 1,723
  • 1
  • 14
  • 23