diff --git a/Example/CoreData/SyncKitCoreDataExample/SyncKitCoreDataExampleTests/CloudKitSynchronizerTests.swift b/Example/CoreData/SyncKitCoreDataExample/SyncKitCoreDataExampleTests/CloudKitSynchronizerTests.swift index 1604ad29..63ce3b96 100644 --- a/Example/CoreData/SyncKitCoreDataExample/SyncKitCoreDataExampleTests/CloudKitSynchronizerTests.swift +++ b/Example/CoreData/SyncKitCoreDataExample/SyncKitCoreDataExampleTests/CloudKitSynchronizerTests.swift @@ -240,11 +240,12 @@ class CloudKitSynchronizerTests: XCTestCase { func testSynchronize_limitExceededErrorInPartialError_decreasesBatchSizeAndEndsWithError() { let expectation = self.expectation(description: "sync finished") let batchSize = synchronizer.batchSize + let innerError = NSError(domain: CKErrorDomain, + code: CKError.limitExceeded.rawValue, + userInfo: nil) let error = NSError(domain: CKErrorDomain, code: CKError.partialFailure.rawValue, - userInfo: [CKPartialErrorsByItemIDKey: ["itemId": NSError(domain: CKErrorDomain, - code: CKError.limitExceeded.rawValue, - userInfo: nil)]]) + userInfo: [CKPartialErrorsByItemIDKey: [CKRecord.ID(recordName: "itemID", zoneID: recordZoneID): innerError]]) mockDatabase.uploadError = error let object = QSObject(identifier: "1", number: 1) mockAdapter.objects = [object] diff --git a/SyncKit/Classes/QSSynchronizer/CloudKitSynchronizer+Sync.swift b/SyncKit/Classes/QSSynchronizer/CloudKitSynchronizer+Sync.swift index 6d7ec813..a1f89dc7 100644 --- a/SyncKit/Classes/QSSynchronizer/CloudKitSynchronizer+Sync.swift +++ b/SyncKit/Classes/QSSynchronizer/CloudKitSynchronizer+Sync.swift @@ -103,7 +103,7 @@ extension CloudKitSynchronizer { func isServerRecordChangedError(_ error: NSError) -> Bool { if error.code == CKError.partialFailure.rawValue, - let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [String: NSError], + let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [CKRecord.ID: NSError], errorsByItemID.values.contains(where: { (error) -> Bool in return error.code == CKError.serverRecordChanged.rawValue }) { @@ -126,7 +126,7 @@ extension CloudKitSynchronizer { func isLimitExceededError(_ error: NSError) -> Bool { if error.code == CKError.partialFailure.rawValue, - let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [String: NSError], + let errorsByItemID = error.userInfo[CKPartialErrorsByItemIDKey] as? [CKRecord.ID: NSError], errorsByItemID.values.contains(where: { (error) -> Bool in return error.code == CKError.limitExceeded.rawValue }) {