Created
          February 22, 2016 21:59 
        
      - 
      
 - 
        
Save MarcusSmith/89643ad257d689ca2348 to your computer and use it in GitHub Desktop.  
    Retrieve persisted long-lived operations, reassign their completion blocks and add them back to a CKDatabase
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | CKContainer.defaultContainer().fetchAllLongLivedOperationIDsWithCompletionHandler { (operationIDs, error) in | |
| guard let operationIDs = operationIDs else { | |
| print("error:", error) | |
| return | |
| } | |
| operationIDs.forEach { (operationID) in | |
| CKContainer.defaultContainer().fetchLongLivedOperationWithID(operationID) { (operation, error) in | |
| guard let operation = operation else { | |
| print("Unable to fetch operation with ID", operationID, "error:", error) | |
| return | |
| } | |
| if let modifyOperation = operation as? CKModifyRecordsOperation { | |
| modifyOperation.modifyRecordsCompletionBlock = { (savedRecords, _, error) in | |
| print("Operation with ID", operation.operationID, "saved records", savedRecords, "error", error) | |
| } | |
| CKContainer.defaultContainer().publicCloudDatabase.addOperation(modifyOperation) | |
| } | |
| } | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment