CloudKit compound query (query with OR)

后端 未结 1 946
南笙
南笙 2021-01-18 12:52

I would like to query CloudKit using OR with two fields. But I can\'t find a way how to do this. What I did is:

NSPredicate *predicate1 = [NSPredicate predic         


        
相关标签:
1条回答
  • 2021-01-18 13:36

    CKQuery supports AND and NOT, so you would imagine you could use simple boolean algebra to create a query based on the fact that NOT(NOT A AND NOT B) == A OR B. HOWEVER, the documentation specifically says:

    "The NOT compound operator is not supported in the following cases:

    You cannot use it to negate an AND compound predicate."

    So you must query for each of the ORed predicates separately save them each as a SET and then take the intersection of the two sets to get the final result

    0 讨论(0)
提交回复
热议问题