NSPredicate包含列表

时间:2013-08-30 18:16:49

标签: ios nspredicate

我有一个标签列表,如第1项,第2项,如果字段与这些项中的任何内容匹配,我想使用NSPredicate来过滤数组。这没有完成它:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY tags CONTAINS[c] %@", tag];
results = [results filteredArrayUsingPredicate:predicate];

1 个答案:

答案 0 :(得分:5)

使用IN运算符,后跟标记数组。

predicate = [NSPredicate predicateWithFormat:@"ANY tags IN %@", theTags];