title: Creating Core Data predicate to get data within one-to-many relationship
body: <p>I have a <code>Loans</code> entity with a <code>returnedDate</code> attribute that can contain a date or be NIL.  There is a to-many relationship with another entity, <code>Items</code> such that items can be related to many <code>Loans</code>.  I would like to create a predicate where I can find all items that do not currently have a <code>loans.returnedDate==NIL</code>.</p>
  
  <p>Assume I currently have the following:</p>
  
  <pre><code>Loan1-item1,returnedDate=NIL
  Loan2-item1,returnedDate=5/4/2012
  Loan3-item2,returnedDate=NIL.
  </code></pre>
  
  <p>I would like a predicate that returns no items.</p>
  
  <pre><code>NSPredicate *pred = [NSPredicate predicateWithFormat:@"!(ANY loaned.returnDate==nil)"];
  </code></pre>
  
  <p>Returns item1.</p>
  
  <pre><code>NSPredicate *pred = [NSPredicate predicateWithFormat:@"(NONE loaned.returnDate==nil)"];
  </code></pre>
  
  <p>Returns item1.</p>
  
  <pre><code>NSPredicate *pred = [NSPredicate predicateWithFormat:@"(ANY loaned.returnDate!=nil)"];
  </code></pre>
  
  <p>Returns item1.</p>
  
  <p>Can someone tell me what logic would return the appropriate results?</p>