Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61774

How to find out what root record is related to CKShare?

Simply I have a CKShare record. Having only this, I need to know what other root CKRecord is related with it.

Since there always need to be root record, I need to know it now. But can't see property in other place than in initializer.

public convenience init(rootRecord: CKRecord)

Any ideas?

Upvotes: 1

Views: 593

Answers (1)

R. Carney
R. Carney

Reputation: 336

You should use the CloudKit operation: CKFetchShareMetadataOperation. This operation is initialized with an array of CKShare().urls and returns the corresponding array of CKShareMetadata?. The CKShareMetadata class contains the rootRecordID: CKRecordID and other interesting properties like the associated share and the participantType: CKShareParticipantType. The participantType can be used to tell if the client who performed the fetch is the owner of the share.

It also contains the optional rootRecord: CKRecord?. You can force fetch all root records by setting shouldFetchRootRecord to true on the CKFetchShareMetadataOperation operation instance before adding to a queue.

Upvotes: 2

Related Questions