I have this predicate
NSPredicate *myPredicate = [NSPredicate predicateWithFormat:@"(date == %@) && (enabled == %@)", date, isEnabled];
At some point, if the logic test is valid, I would like to add a third filter to this predicate, something like
if (testValid) { // use some magic to add a third option here // the third option is "&& (paid == %@") // and the condition is given by isPaid // the idea is to append a third condition on myPredicate, making it like // myPredicate = // [NSPredicate predicateWithFormat:@"(date == %@) && (enabled == %@) && (paid == %@)", date, isEnabled, isPaid]; }
I believe that I can create an NSMutableString for the format and add a third part if necessary, but I suspect there is a way to do this using NSPredicate in a more elegant way.
How can I do it? Is it possible?
thanks
source share