NSPredicate与(匹配或匹配)AND匹配

时间:2016-05-12 19:53:03

标签: objective-c nspredicate

我想要一个谓词:

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

但是()不像我想的那样工作,就像它在if stmt中一样:

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

如果'condition1'或'condition2'为真加上'otherCondition'为真,则stmt为真。

我可以使用NSPredicate吗?

1 个答案:

答案 0 :(得分:1)

def update_session(request):
    if not request.is_ajax() or not request.method=='POST':
        return HttpResponseNotAllowed(['POST'])

    request.session['mykey'] = 'myvalue'
    return HttpResponse('ok')