2017-12-19 2 views
0

Vorerst und Single-Sharing Ich mache es wie folgt aus:Gibt es eine Möglichkeit, mehrfache CK-Shares mit einem UICloudSharingController zu erstellen?

//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) 

Aber wie kann ich dies tun für 2 ckshares? Ist es möglich?

Antwort

1

Sicher, wo Sie die share hinzufügen, richten Sie einfach so viele, wie Sie möchten, z. let share1 = ...; let share2 = ...;. Dann fügen Sie in dem Initialisierer CKModifyRecordsOperation jede der Freigaben hinzu, z. CKModifyRecordsOperation(recordsToSave: [record1, share1, record2, share2].

+0

es klingt gut. –

Verwandte Themen