title: CoreData - one-to-many modeled relationship comes out as one-to-one
body: <p>I am new to Core Data modeling, and I am having a hard time understanding how one-to-many relationships work.  </p>
  
  <p>I have a parent entity called <code>Task</code>, which can have several instances of <code>Comment</code> entity.  I modeled it like this: on <code>Comments</code>, a relationship to <code>Task</code> called <code>task</code> with the <code>Task</code> entity a destination. On <code>Task</code>, a relationship called <code>comments</code>, with <code>Comment</code> as its destination, and both relationships are each others inverse.  </p>
  
  <p>Not defining an inverse results in either warnings or error messages. While modeling this way works, I've noticed that once I create a second comment for a given <code>Task</code>, the first is replaced (one-to-one relationship).  </p>
  
  <p>What would be the correct way to tell the Core Data Model that this relationship allows many comments in one <code>Task</code>?</p>
  
  <p>Also, since CoreData seems to manage primary keys on its own, how would I create an <code>NSPredicate</code> to retrieve  all comments for a given Task?</p>
  
  <p>Thanks for any suggestions!</p>