I need to set up my NSPredicate base on actual value stored in CoreDate.
Assuming we have a CoreData entity: "Graduate". we want to fetch graduate whose graduation date is earlier than Date1 if his/her graduation date is not null. Otherwise, I want to check if his/her birthday is earlier than Date2.
The predicate would look like this:
"if graduationDate != null graduationDate < %@ else birthday < %@"
So I actually have two predicate. The second one should only come into effect if the field which first predicate wants to check is null.
My thoughts:
I can process this in my APP instead of CoreData, but just wonder is there a way to use only one NSPredicate to sort it out.
Some posts mentioned that NSPredicate is an equivalent to SQL Where Clause, which makes sense to me. And I think what I need here is going to beyond what Where Clause is capable of.
My question is not about how to filter fetch result using NSPredicate. It's about how to setup NSpredicate using a flow control like if else clause