Gerard
Gerard

Reputation: 4848

Allowing duplicate records in Core Data Many-to-many relationship

I have an Item and Person relationship which is a many to many relationship.

I want a person to be able to own 2 different instances of an item (which are represented by the same record in the DB). I want my link table to be able to look something like:

Person ID | Item ID

1     |    3
2     |    4
1     |    3

Unfortunately when a person's items are represented by NSSet. So when I try to set an additional dupe object in the set, I'm guessing NSSet automatically removes it.

Any help?

Upvotes: 0

Views: 104

Answers (1)

Marcus S. Zarra
Marcus S. Zarra

Reputation: 46718

Create a real entity between the Person and Item entity. Then you can create as many of those "join" entities as you want. Or you can stick another attribute in there such as "quantity" instead of having multiple join entities.

Upvotes: 1

Related Questions