Joris416
Joris416

Reputation: 4882

How to fetch records from a specific record zone

I'm building an app that allows users to manage their products in the cloud. To do this, I have a Product Record type in iCloud. I use this record type for two purposes:

Now I have one problem: When I try to fetch all products for my product manager, it also fetches the products from the Checks record zone - the zone containing the transactions and the products they contain. I obviously need to fetch only the products from the Products Record Zone.

There doesn't seem to be much reference for this on the internet, so I figured I'd post a question here for, also for future reference.

Is there a way in CloudKit to fetch records from a specific record zone?

Upvotes: 2

Views: 842

Answers (1)

Edwin Vermeer
Edwin Vermeer

Reputation: 13127

You could use a CKQueryOperation and set the zoneID like this:

    let operation = CKQueryOperation(query: query)
    operation.zoneID = CKRecordZoneID(zoneName: "name", ownerName: "me")

Upvotes: 4

Related Questions