Spike Lee
Spike Lee

Reputation: 411

I am having problems with my NSPredicate

I'm trying the following comparison but it does not work.

What is the appropriate syntax to use both the or/and operator within the same context?

NSPredicate* predicate = [NSPredicate predicateWithFormat:@"((day || day2 ==%@) && CourseTitle==%@)",day,courseSelected];
rows = [[courseArray filteredArrayUsingPredicate:predicate]retain];

Upvotes: 0

Views: 62

Answers (1)

0xSina
0xSina

Reputation: 21593

Try:

NSPredicate* predicate = [NSPredicate predicateWithFormat:@"(((day == %@) OR (day2 == %@)) && CourseTitle==%@)",day, day, courseSelected];
rows = [[courseArray filteredArrayUsingPredicate:predicate]retain];

Upvotes: 4

Related Questions