我有一个标签列表,如第1项,第2项,如果字段与这些项中的任何内容匹配,我想使用NSPredicate来过滤数组。这没有完成它:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY tags CONTAINS[c] %@", tag];
results = [results filteredArrayUsingPredicate:predicate];
答案 0 :(得分:5)
使用IN运算符,后跟标记数组。
predicate = [NSPredicate predicateWithFormat:@"ANY tags IN %@", theTags];