title: NSOutlineView and Core Data 1 → Many Relationships
body: <p>I have a Core Data model that supports a 1 → Many relationship (1 Folder to many Phrases). At the moment I'm just displaying the Phrases on a flat <code>NSTableView</code> using Core Data Bindings to a <code>NSArrayController</code> to glue everything together - this is working happily.</p>
  
  <p>I'm trying to experiment with an <code>NSOutlineView</code> to achieve the same result but showing the folders as well. I've tried a similar binding structure that I'm already using with the <code>NSTableView</code> but I'm not making any headway. What steps should I take to move from a flat <code>NSTableView</code> to a <code>NSOutlineView</code> with 'depth'? </p>
  
  <p>Here's my MOM:
  <img src="https://i.stack.imgur.com/0dIKb.png" alt="managed object model. We spell mother &#39;mum&#39; in New Zealand, so not as funny as it could have been."></p>
  
  <p>Top level folders, bottom level phrases. No nesting. I'm not an animal. </p>
  
  <p>NSTreeController</p>
  
  <ul>
  <li>I have a <code>NSTreeController</code> bound to the array controller for <code>arrangedObjects</code> on <code>Controller Content</code></li>
  <li>It is set to 'Entity Name' mode with an entity name of <code>Folder</code> (this feels wrong)</li>
  <li><code>phrases</code> is set to the children key path</li>
  <li>Prepares Content is true</li>
  <li>It's mOC is set to a valid mOC</li>
  </ul>
  
  <p>NSOutlineView</p>
  
  <ul>
  <li>Outline View Content is bound to the Tree Controller using arrangedObjects as the Key and string as the Key Path</li>
  </ul>
  
  <p>The Phrase NSManagedObject</p>
  
  <ul>
  <li>has an extension called 'phrases' which returns an empty set, since it'll never have children.</li>
  </ul>
  
  <p>When I do this, I get this as a result:</p>
  
  <blockquote>
    <p>[APPNAME.Folder copyWithZone:]: </p>
  </blockquote>
  
  <p>The <a href="https://lifeasclay.wordpress.com/2011/02/13/connecting-nsoutlineview-to-core-data-in-10-6-part-1-ordered-trees/" rel="nofollow noreferrer">tutorial that got me this far</a> had nested objects and only one type of entity, where as I have two. What do I need to have an accurate representation of my core data objects in a <code>NSOutlineView</code>?</p>