deeje / CloudCore

Robust CoreData-CloudKit synchronization: offline editing, relationships, private, shared and public databases, field-level deltas, encrypted values, cacheable assets, and more.
MIT License
157 stars 17 forks source link

Override Persistent History Clearing #5

Open deeje opened 5 years ago

deeje commented 5 years ago

currently, CloudCore assumes ownership of NSPersistentHistoryTracking, clearing out history after its been properly pushed to CloudKit. But NSPersistentHistoryTracking is also useful for shared containers and app extensions. Need to refactor such that apps can override default history clearing behavior.

noecantu commented 4 years ago

How would you handle the replacement of Core Data?

do {
       try container.persistentStoreCoordinator.replacePersistentStore(at: storeUrl, destinationOptions: nil, withPersistentStoreFrom: inputURL, sourceOptions: nil, ofType: NSSQLiteStoreType)
} catch {
      print("Failed to replace persistent container...NC") }//End do-catch
}

I can successfully load the Core Data backup but get NSPersistentHistoryToken errors:

Fatal error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134501 "(null)" UserInfo={Reason=Store - (
    "4F49429F-3853-4978-9A43-AE28A1B644AE"
) not found in token - <NSPersistentHistoryToken - {
    "4F49429F-3853-4978-9A43-AE28A1B644AE" = 1;
}>}, ["Reason": Store - (
    "4F49429F-3853-4978-9A43-AE28A1B644AE"
)

I'm having a hard time Manually clearing Persistent History Tokens. Any advice?