0

Let's say I have two CloudKit record types:

  • Company

    • name (string)
    • etc...
  • Employee

    • first name (string)
    • etc...
    • company (reference to Company)

In my app if I have an array Companies, is there a way to query CloudKit for all Employees whose company is in this array with a single query? Obviously I could go through the companies array and query one by one, but if this array is large then that's going to be a lot slower.

The docs say that you can reference an array in a CKQuery predicate, but doesn't say how.

1 Answer 1

2

Yes you can use the predicate

NSPredicate(“%k IN %@“, company, arrayofcompaniesReference)

  • company is the key in employee record type
  • arrayOfCompaniesReference is the array of reference of companies you have.
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.