title: How do I use NSTreeController, NSOutlineView and Core Data with an "invisible" root item?
body: <p>I have a Core Data model which consists of a simple tree of a particular entity, which has two relationships, <code>parent</code> and <code>children</code>. I have an <code>NSTreeController</code> managing the model, with an <code>NSOutlineView</code> bound to the <code>NSTreeController</code>.</p>
  
  <p>My problem is that I need a single root object, but this should not display in the outline view, only its children should be displayed at the top level of the outline view. If I set the fetch predicate of the <code>NSTreeController</code> in Interface Builder to <code>parent == nil</code>, everything works fine except the root item is visible as the top level item in the outline view.</p>
  
  <p>My entity has an attribute, <code>isRootItem</code>, that is true for the root item only.</p>
  
  <p>My model looks like this:</p>
  
  <pre><code>Node 1
  |
  +-Node 2
    |   |
    |   +-Node 5
    |
    Node 3
    |
    Node 4
  </code></pre>
  
  <p>The outline view should look like this:</p>
  
  <p><a href="https://i.stack.imgur.com/fJEqo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fJEqo.png" alt="Outline View Image"></a><br>
  <sub>(source: <a href="http://menumachine.com/quickies/nodes.png" rel="nofollow noreferrer">menumachine.com</a>)</sub>  </p>
  
  <p>I need to display Nodes 2, 3 and 4 at the top level of the outline view (Node 1 should not be visible), but still have their parent be "Node 1". Node 1 has a value of <code>YES</code> for <code>isRootItem</code> and all the others have <code>NO</code>.</p>
  
  <p>If I set the fetch predicate of the tree controller to <code>parent.isRootItem == 1</code>, this displays the tree correctly, but as soon as I add a new item to the top level it fails because the tree controller does not assign the "invisible" root item as the parent of the new item.</p>
  
  <p>Is there a way to get the <code>NSTreeController</code>/<code>NSOutlineView</code> combination to work in this situation?</p>