I am toying with CloudKit, saving records and assets (using the private database). Managed to successfully save an CKAsset, it ends up in the _defaultZone. My Core Data Objects however somehow end up in the zone called com.apple.coredata.cloudkit.zone. I haven’t done anything explicitly with zones anywhere, how do I make both use the same (preferably _defaultZone) zone?
I think this is needed, because I give the asset an reference to the Game entity it belongs to, thinking this would enable cascaded delete (Game gets deleted, so do all assets for that game). Game is my Core Data entity
// Game (reference record)
let gameName = game.objectID.uriRepresentation().absoluteString
let gameID = CKRecord.ID(recordName: gameName)
// Create a CKRecord for the Game Image, referencing the Game
let iconImageRecord = CKRecord(recordType: "GameIconImages")
iconImageRecord["oid"] = gameName
iconImageRecord["gid"] = id.uuidString
iconImageRecord["game"] = CKRecord.Reference(recordID: gameID, action: .deleteSelf)
The extra id's are for testing/checking. I checked in the CloudKit dashboard and the reference id is correct (equal to coredata objectid), but when I click it, I get 'record not found'. My guess this is because the CKRecord and the CoreData records are in two different zones...?
Any help really appreciated, banging my head over it way too long...