title: CoreData model with nested object relationships as a datasource?
body: <p>I have a very simple data model that consists of 2 objects — a <code>Section</code> and an <code>Item</code>. Each <code>Section</code> has a to-many child relationship to other <code>Section</code> objects as well as a to-one parent relationship with another <code>Section</code> object. Every section has a to-many relationship to <code>Item</code> objects. </p>
  
  <p><img src="https://i.stack.imgur.com/PE0d8.png" alt="data model"></p>
  
  <p>Structure aside, some <code>Section</code> objects have no <code>Item</code> objects, and others (at the bottom of the hierarchy) have no <code>Section</code> child objects. </p>
  
  <p>I want to create a tableview that will use <code>Section</code> objects to create the section headers, and then display the <code>Item</code> objects as tableViewCells that are a part of that <code>Section</code>. I also want table headers to appear if the <code>Section</code> has no <code>Items</code>, because seeing the hierarchy is important.</p>
  
  <p>Given a random <code>Section</code> object, how would I go about fetching and displaying this data? Do I need to create a nested loop that flattens the data in an array, or is there some awesome way to leverage predicates and <code>NSFetchedResultsController</code>? </p>