CloudKit: 如何使用CKFetchShareParticipants 和CKModifyRecords 获取share URL?

CloudKit: How to use CKFetchShareParticipants and CKModifyRecords to get share URL?

我正在关注此 WWDC video 和一些在线找到的示例代码(遗憾的是 Apple 没有在其 WWDC 演讲中包含示例代码),使用下面的代码我 CKShareParticipant ok但是这个块 modOperation.modifyRecordsCompletionBlock 根本没有返回,我做错了什么?

 private func share(record: CKRecord) {
        
        let share = CKShare(rootRecord: record)
        // save
        let operation = CKFetchShareParticipantsOperation(userIdentityLookupInfos: [CKUserIdentity.LookupInfo(emailAddress: "friendsEmail@gmail.com")])
        
        var participants = [CKShare.Participant]()
        
        // Collect the participants as CloudKit generates them.
        operation.shareParticipantFetchedBlock = { participant in
           
            participants.append(participant)
        }
        
        // If the operation fails, return the error to the caller.
        // Otherwise, return the array of participants.
        operation.fetchShareParticipantsCompletionBlock = { error in
            
            if let error = error {
                print("error: ", error)
            } else {
            
                for participant in participants {
                    print("we have a participant! = \(participant)")
                    
                    let modOperation: CKModifyRecordsOperation = CKModifyRecordsOperation(recordsToSave: [record, share], recordIDsToDelete: nil)
                    
                    operation.shareParticipantFetchedBlock = { participant in
                        participant.permission = .readOnly
                        share.addParticipant(participant)
                        
                        modOperation.savePolicy = .ifServerRecordUnchanged
                        
                        //nothing in this block gets called
                        modOperation.modifyRecordsCompletionBlock = {records, recordIDs, error in
                            if let error = error {
                                print("error in modifying the records: ", error)
                            } else {
                                print("TESTING records = \(records) recordIDs = \(recordIDs)")
                            }
                            
                        }
                    }
                
                    modOperation.qualityOfService = .userInitiated
                    container.privateCloudDatabase.add(modOperation)
                    
                    
                }   //end of for participant in participants
            }
            
            
            
        } //end of operation.fetchShareParticipantsCompletionBlock
        
        // Set an appropriate QoS and add the operation to the
        // container's queue to execute it.
        operation.qualityOfService = .userInitiated
        container.add(operation) //It was important to make sure this is the same container
    }

这只是一个拼写错误,我只需要删除 modOperation

声明下的这一行 operation.shareParticipantFetchedBlock = { participant in