Ezekiel
Ezekiel

Reputation: 2514

Fetching CKRecordZone from a CKRecord

Scenario:

I have a CKRecord which I have fetched from the server. The record exists inside a custom zone for which I do not know the identifier and do not have a CKRecordZone object for.

I need to make a call to CKDatabase.perform(query:inZoneWith:completion:) to get the records in the database which are components of the root shared record (which requires such a call) however without having a CKRecordZoneID (from a CKRecordZone) I am forced to iterate through every CKRecordZone in the shared database and perform the query until a matching record is found.

In summary: I want to take a CKRecord and find the CKRecordZone it exists in. Is this possible? Or is my method flawed and can I perform a query without the CKRecordZoneID?.

Upvotes: 0

Views: 362

Answers (1)

Ezekiel
Ezekiel

Reputation: 2514

To find the CKRecordZoneID of a given record, the recordID property is helpful:

(record).recordID.zoneID yields the CKRecordZoneID that the CKRecord exists in.

Upvotes: 1

Related Questions