我有NSPredicate
四个语句/参数。似乎所有这些都不是“包含”的。它看起来像这样:NSPredicate with multiple statements
predicate = [NSPredicate predicateWithFormat:@"user.youFollow = 1 || user.userId = %@ && user.youMuted = 0 && postId >= %d", [AppController sharedAppController].currentUser.userId, self.currentMinId.integerValue];
看起来像最后一部分:&& postId >= %d
,被忽略。如果我尝试:
predicate = [NSPredicate predicateWithFormat:@"user.youFollow = 1 || user.userId = %@ && user.youMuted = 0 && postId = 0", [AppController sharedAppController].currentUser.userId, self.currentMinId.integerValue];
我得到相同的结果(应该是0)。我不知道这样的谓词应该看起来如何?
你有没有试着用括号?只是为了看看它是否是一个优先问题... – Francesco
我试过了:'(user.youFollow = 1 || user.userId =%@)&&(user.youMuted = 0 && postId> =%d)'。 – Anders
'NSLog(@“%@”,[predicate description]);'print? –