title: CoreData - select specific entry from one to many relationship
body: <p>Damn you short titles! :p</p>
  
  <p>Basically I have an entity named "threads" and I have an entity named "messages". I have a one to many relationship from threads ->> messages (and a one to one inverse relationship).</p>
  
  <p>What I need to do is get all the records from the threads entity and for each one I need to get the message with the latest timestamp (this is just an int in the "lastUpdated" attribute, so the highest number I guess will suffice).</p>
  
  <p>I'm not sure what other information you may want, here is a screenshot of my entities:</p>
  
  <p><img src="https://i.stack.imgur.com/YeMRX.png" alt="alt text"></p>
  
  <p>I'm sure there must be a better way than iterating through all the records and comparing the threadIds?</p>
  
  <p>Thank you.</p>