I am trying to use the new API provided by WWDC21 to create Core Data databases that can be shared.
When I do the sharing for an NSManageObject, I tried to experiment with 2 methods.
1: Using UICloudSharingController's
UICloudSharingController(preparationHandler: (UICloudSharingController, @escaping (CKShare?, CKContainer?, Error?) -> Void) -> Void)
method. Currently this method works and the participants can get all the data after accepting the invitation.
2:Use NSPersistentContainer's
share(_ managedObjects: [NSManagedObject], to share: CKShare?) async throws -> (Set<NSManagedObjectID>, CKShare, CKContainer)
method.
First get ckshare, then call
UICloudSharingController(share:, container: )
With this approach, after accepting the invitation, the participant only gets the data generated after the creation of the ckshare, and the data before the ckshare is never fetched
I'm not sure if it's an error in the token generated by the share method of the NSPersistentContainer or something else. Has anyone encountered a similar situation?