What are the pros and cons for using a single NSPredicate with a value like "Condition1 AND condition2" vs. using a NSCompoundPredicate with two subpredicates?
Even if I construct it dynamically, the first option seems much more compact to code.
You've almost answered your own question - it's more a cleanliness of code question than a performance question!
NSCompoundPredicate
is more useful if you are creating lots of conditions in seperate parts of your code that you then want to combine.
If your predicate is being created all in one place, just use ' AND ' in a format string.
It's really up to you when you decide that your predicate is complicated enough that creating it needs to be split into separate methods.
i.e.
If it's just a AND b
then use a single predicate
If it's a AND (b OR c OR c) AND (e OR b)
then use compound predicates!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With