我有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? –