2011-09-19 95 views
0

我在尝试下面的比较,但它不起作用。我遇到了我的NSPredicate问题

在相同的上下文中使用or和/ or操作符的语法是什么?

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

回答

4

尝试:

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