我正在尝试使用 NSPredicate
搜索 Core Data
以查找与多个 NSStrings
匹配的所有结果。以下适用于使用“a”查找结果,但如何设置 NSPredicate 以查找“a”、“b”和“c”?
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"Result == 'a'"]];
最佳答案
NSPredicate *predicate = [NSPredicate predicateWithFormat:[NSString stringWithFormat:@"Result == 'a' OR Result == 'b' OR Result == 'c'"]];
或
EDIT:
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"self.Result IN %@",[NSArray arrayWithObjects:@"a",@"b",@"c", nil]];
关于ios - 使用 NSPredicate 搜索一系列 NSString,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26688719/