I've got a complex NSPredicate
problem that I just cannot solve.
My data structure is as follows:
Category - has many Titles
Title - has many Products
Title - has latestProduct property (title.latestProduct
)
Titles can be excluded via excluded property (title.excluded = YES
)
Products can be excluded via excluded property (product.excluded = YES
)
The result I am looking for: I need to fetch a list of all categories in the system, however I want to exclude categories where:
- All category titles are excluded
(category.titles.excluded == YES)
OR
- All latest products are excluded (
category.titles.latestProduct.excluded == YES
)
OR (and this is the tough part for me)
- The SUM of the count of (
category.titles.excluded == YES
) and count of (category.titles.latestProduct.excluded == YES
) is equal to the count of category titles (category.titles.count
)
I can describe my problem in plain english but cannot work out the proper way to format this as a predicate. Any help would be greatly appreciated thanks!