title: How do I create a FetchRequest predicate for a child entity where the parent entity satisfies a NSPredicate
body: <p>I have two Core Data entities: <code>Parent</code> and <code>Child</code>.
  <code>Parent</code> has a property <code>children</code> for the set of children</p>
  <p>Each <code>Child</code> has a <code>parent</code> property linking it to its parent, and an <code>age</code> property.
  (My data is more complex than this, but that's not relevant to the question)</p>
  <p>I have a <code>NSPredicate</code> for the <code>Parent</code> entity that selects a set of parents and a <code>NSPredicate</code> for the <code>Child</code> entity that selects entities based on age</p>
  <p>What I want to do is construct a single <code>NSPredicate</code> for a <code>FetchRequest&lt;Child&gt;</code> that returns the set of <code>Child</code> entities that meets both of the individual predicates</p>
  <p>I know I can retrieve an array of <code>Parent</code> entities that meet their predicate ('<code>parents</code>') then have a child predicate something like <code>NSPredicate(format: &quot;parent IN %@&quot;, parents)</code> and include that in a compound AND with the child predicate, but there could be hundreds of parents meeting their predicate and it looks to me a but of a kludge to have two separate queries.</p>
  <p>The <code>FetchRequest</code> needs to be <code>FetchRequest&lt;Child&gt;</code> as it's used in a SwiftUI view, so I can't just build an array of the results.</p>
  <p>I suspect that I can do this with a SUBQUERY predicate but I can't work out how to embed the parent predicate into the SUBQUERY. I get errors like <code>Problem with subpredicate TRUEPREDICATE</code> in the predicate string for the <code>Parent</code> entity.</p>
  <p>Hopefully that makes sense? Any ideas or suggestions?</p>
  <p>Thanks</p>