title: Models with refference to another models - saving using NSCoding
body: <p>I'm creating some kind of games tracker and want to ask if this kind of design is bad choice. </p>
  
  <p>I'm using MVC architecture and inside my models I have refferences to other models, i.e. inside Player model I have</p>
  
  <pre><code>var name: String
  var lastTimePlayed: Date?
  var timesPlayed: Int
  let playerID: String
  var gamesPlayed = [Game]()
  var matchesPlayed = [Game: [Match]]()
  var gamesPlace = [Game: [Int]]()
  var gamesPoints = [Game: [Int]]()
  </code></pre>
  
  <p>Here is and image of how it looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/sktup.png" rel="nofollow noreferrer">Graph of all models used</a>.</p>
  
  <p>Arrows indicate that model keeps a refference to another model.</p>
  
  <p>Would it be better to save just gameID and matchID or gameName instead of refferences to Game and Match models? It is easier for me to keep the direct refferences, so I can have access to dates of last matches etc. but I can do it the other way, too.</p>
  
  <p>Of course, when I'm removing a model, I take care of all those refferences and remove them too, so there is no memory leak.</p>
  
  <p>My second question is - will I have a problem when I try to save those using NSCoding (using <code>NSKeyedArchiver.archiveRootObject</code> at stores)? Won't it go in loop-like cycle going from Player to Game to Match and then to Player again?</p>
  
  <p>Thank you for your help!</p>