Reputation: 1403
Is it possible to use if
inside NSPredicate
? In my Student
table there is one column sex
(male/female). I want to use two queries for male and female.
NSPredicate *pred = [NSPredicate predicateWithFormat:@"if(sex=='male') query1 Else query2" ];
How do I implement this?
Upvotes: 0
Views: 52
Reputation: 8482
You can use AND
and OR
to achieve this:
(sex = 'male' AND <query1>) OR (sex != 'male' AND <query2>)
Upvotes: 1