Swift Core Data: FetchRequest with predicate over children

126 Views Asked by At

I have a Category entity with Scan child entities (one to many relationship). Now I would like to fetch all Categories with a running a predicate on the children.

Details: Category has a child relationship of Scans which is a Set. Scan has an isSent bool which I want to use in the predicate.

I want to fetch all Categories but filter the Scan children by isSent = true.

This code does not work:

let scans: FetchRequest<Scan>
scans = FetchRequest<Category>(entity: Category.entity(), sortDescriptors: [
        ], predicate: NSPredicate(format: "scans.isSent = %d", true))

Is there any way to write a FetchRequest with using a predicate on the children?

Thanks!

0

There are 0 best solutions below