title: CoreData - Where to include reference to object?
body: <p>I'm in the process of moving over the content library of my iOS app from being purely JSON, to leveraging CoreData.</p>
  
  <p>I've produced my datamodels but have one point that I am unclear about, and was hoping to get the ideal approach:</p>
  
  <p>I understand using CoreData to store entries about my individual pieces of content, but want to understand the "right" way to have my produced class have a property or variable that references a functional object that USES the settings in the CoreData entry.</p>
  
  <p>Basic structure:</p>
  
  <ul>
  <li><p><code>InstrumentEntry.xcdatamodeld</code>: Contains settings for individual "instrument" entries</p></li>
  <li><p>Manual codegen produces <code>Instrument+CoreDataClass</code> and <code>Instrument+CoreDataProperties</code></p></li>
  <li><p>Instrument.swift: Defines a class which is responsible for producing audio, receiving events, etc.</p></li>
  </ul>
  
  <p>So,
  In my <code>InstrumentEntry+CoreDataClass.swift</code>, can I simply add something like <code>var actualInstrument: Instrument</code>, or, is this something that I include in the actual Data Model as an Attribute or Property?</p>
  
  <p><strong>OR</strong></p>
  
  <p>Do I create my "actualInstrument" and simply have it READ an entry from the CoreData context, rather than maintaining ownership FROM the CD Entry TO an <code>Instrument</code> object?</p>
  
  <p>Thanks!</p>
  
  <p><a href="https://i.stack.imgur.com/0HOZ6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0HOZ6.png" alt="enter image description here"></a></p>