Get CKRecord from core data entity

Hi,


In SwiftUI, we can work with CoreData and CloudKit mostly without doing anything special because CloudKit is managing everything for us in terms of saves, deletes, creates, and updates.


However, if I want to share cloudkit records, I would like to access the associate CKRecord of a core data entity.


Can someone please help me understand how to go about this? I cannot find any information that shows this in SwiftUI scenarios. Documentation and examples that I have found assume UIKit frameworks that are working with the CKRecords directly from the start.


Thank you!

Hi Justin,

I have the same trouble but using UIKit. CloudKit can manage mirroring with CoreData everywhere either SwiftUI or UIKit, so i am using the same feature as you do.
And now I am stuck because cannot find info how to get CKRecord from my synchronised CoreData Entities.

Did you find the solution?
I've found the solution. On the NSPersistentCloudKitContainer we have to simply call

Code Block
persistentContainer.record(for: object.objectID)


where object is NSManagedObject
Get CKRecord from core data entity
 
 
Q