Use of OR operator on Cloudkit predicate

后端 未结 1 1606
情书的邮戳
情书的邮戳 2021-01-21 19:54

I have a cloudkit record with 5 fields:

Active
User1
User2
User3
User4

I am trying to pick the record where one of the 4 user fields match with

相关标签:
1条回答
  • 2021-01-21 20:31

    Cloud Kit's CKQuery doesn't support OR in a predicate. See the documentation for CKQuery. It shows all the supported predicate operators and while AND and NOT are supported, OR is not.

    One possible replacement for OR would be IN. I've only seen this where you wish to see if a single field contains one of several values. But your case is in reverse. Try the following but it may not work.

    var userID = "0984093843897"
    NSPredicate(format:"%@ IN { %K, %K, %K, %K } AND active = true", userID, "userID1", "userID2", "userID3", "userID4"]
    
    0 讨论(0)
提交回复
热议问题