I have two entities: match and player , which I have set up with an intermediate table matchplayer as players can play multiple matches, and matches will have multiple players. I have views where I can add, amend and delete both matches and players separately, but I am confused about how to populate the matchplayer entity. I have set up the matchplayer entity with no attributes but with relationships to both the match and player entities.
I have a view managing match details, and from there it loads a tableview of all players where I can select the players I want to 'connect' to the match. But that's where I get stuck. What do I add to the matchplayer entity to store the relationship?
you don't need to create a separate entity just to maintain relationship.
What you can do is you maintain to many relationship from match entity to player entity.
Suppose name that relationship as playerInMatch. Now each managedObjectContext of match that you insert in match entity, you can insert multiple players to this managedObjectContext using addPlayerInMatch: method (i.e the accessor method that automatically gets generated when you created modal classes).
Now during retrival of a particular match , you can retrive a complete set of players of that match through its relationship.Using that you can delete or add any player to that set if you want to.
(I have briefly explained you the idea hoping you have a clear understanding of using core data relationship.If you are not perfectly clear with core data check out following tutorial:
http://cocoadevcentral.com/articles/000085.php