2
我有以下謂詞的一個問題:NSPredicate使用或返回錯誤
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(creatorUserRecordID == %@) OR (toUser == %@)", userId, userId];
當我用它查詢CKQuery *query = [[CKQuery alloc] initWithRecordType:@"Message" predicate:predicate];
我有一個錯誤,指出:「CKException」,理由是:「意外的表情」。
當我使用這兩個seperately這樣的:
NSPredicate *predicate1 = [NSPredicate predicateWithFormat:@"(creatorUserRecordID == %@)", userId];
NSPredicate *predicate2 = [NSPredicate predicateWithFormat:@"(toUser == %@)", userId];
然後用這些謂詞能正常工作的一個進行查詢。我也嘗試使用NSCompoundPredicate,但結果總是相同的...任何想法?
我在文檔中發現的是:基本化合物謂詞 AND,&& 邏輯AND。 OR,|| 邏輯或。 不,! 邏輯NOT。我錯了嗎? – Wojtek
好吧。雖然NSPredicate可以使用,但CKQuery不允許使用OR進行謂詞。我的錯。你能否提示我如何用OR查詢CloudKit? – Wojtek