现在和单人分享我这样做:
//here I have access to record fetched from cloud database
let controller = UICloudSharingController { controller, preparationCompletionHandler in
let share = CKShare(rootRecord: record)
share[CKShareTitleKey] = territory.name as CKRecordValue
share[CKShareTypeKey] = "pl.blueworld.fieldservice" as CKRecordValue
share.publicPermission = .readWrite
let operation = CKModifyRecordsOperation(recordsToSave: [record, share], recordIDsToDelete: nil) //what happens if I pass here a three records and three related ckshares?
operation.savePolicy = .ifServerRecordUnchanged
operation.modifyRecordsCompletionBlock = { records, recordIds, error in
preparationCompletionHandler(share, CloudAssistant.shared.container, error) //how can I do it for every created ckshare?
}
operation.database = territory.database
CloudAssistant.shared.operationQueue.addOperation(operation)
}
controller.delegate = self
controller.popoverPresentationController?.barButtonItem = self.collaborateBarButtonItem
present(controller, animated: true)
但我怎么能为2个ckshares做到这一点?有可能吗?
答案 0 :(得分:1)
当然,在您添加share
的位置,只需根据需要设置多个,例如let share1 = ...; let share2 = ...;
。然后在CKModifyRecordsOperation
初始化程序中,添加每个共享,例如CKModifyRecordsOperation(recordsToSave: [record1, share1, record2, share2]
。