I’ve been learning about CloudKit sharing and using the code techniques in Apple’s CloudKitShare sample project found in Apple‘s documentation.
Upon reading Apple stock vacation for CKFetchDatabaseChangesOperation and CKFetchRecordZoneChangesOperation, I started wondering why they use both those classes. It seems only using CKFetchDatabaseChangesOperation would be enough. I think they use CKFetchRecordZoneChangesOperation because that sample project creates and deletes be lots of zones and also shares records to the shared database.
If I am only using two custom zones, even though I share records, which means when a CKShare is accepted and the record zone it belongs to doesn’t exist in the shared database, then CloudKit automatically creates that record zone in that shared database, would I still need to use the CKFetchRecordZoneChangesOperation? The documentation for CKFetchDatabaseChangesOperation doesn’t say that CKFetchRecordZoneChangesOperation would be needed if I use CKFetchDatabaseChangesOperation.
The answer to my question has to do with whether the CKFetchRecordZoneChangesOperation fetches records from both the private database and the shared database. I wonder whether the fact that CKFetchRecordZoneChangesOperation inherits from CKDatabaseOperation and is added to the queue of a CKDatabase necessarily means that it only fetches records from that specific CKDatabase.
I did just realize that the CKFetchDatabaseChangesOperation returns only zone ids, and not any records or record ids. That means I have to use the zone ids I get from that operation in order to fetch records and record ids from the zones with those record ids. Can that only be done with CKFetchRecordZoneChangesOperation? If so, I still need to know whether CKFetchRecordZoneChangesOperation fetches only the records and record ids in the zone with the ids I provided my CKFetchRecordZoneChangesOperation with.