Quantm Quantm - 4 months ago 11
iOS Question

Core Data - "days" and "tasks" (to-many-relation) - How to fetch all tasks of a day?

I have the entities

. One day has many tasks and one task has many days.

I want to fetch all tasks of a certain day. I think you have to use predicates for that. I tried this:

let filterPredicate = NSPredicate(format: "ANY days == %@", argumentArray: [Project.Days.current])
fetchRequest.predicate = filterPredicate

But it's not working. Any ideas? I tried searching for this, but I just don't know what to search for, it's hard to describe the problem.


Can't test this at the moment but I think you would use "%@ IN days" as the predicate

Alternatively just fetch the day that you are interested in and use the array that contains the tasks