NSPredicate with (match OR match) AND match



我想要一个谓词:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(self isKindOfClass: %@ || self isKindOfClass: %@) AND isActive == YES", [TestClass1 class], [TestClass2 class]];

但是()并没有像我想象的那样工作,因为它在if stmt:中是这样的

if ((condition1 || condition2) && otherCondition) {
}

如果"condition1"或"condition2"为true加上"otherCondition"为true,则if stmt将为true。

我可以用NSPredicate吗?

[NSPredicate predicateWithFormat:@"(isActive == YES AND (class == %@ OR class == %@))", [TestClass1 class], [TestClass2 class]];

最新更新