Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CKReference .DeleteSelf attribute has no effect

How does .DeleteSelf really work? Docs says:

When the reference object’s action is set to CKReferenceActionDeleteSelf, the target of the reference—that is, the record stored in the reference’s recordID property—becomes the owner of the source record. Deleting the target (owner) record deletes all its source records.

but my impression is that deleting a target will not always delete source. And it is quite annoying when it remains in the container, client downloads it, and expect that the reference point to somewhere, but target does not exist when building up slice of the server data store on client?

How do you treat this case? You ignore that sort of records? Or periodically you look up the CloudKit storage, searching for corrupt records to delete them?

Or instead of deleting a record is it better to set an attribute that it is in a deleted state, but keep it in the database?

like image 478
János Avatar asked Sep 25 '15 19:09

János


1 Answers

I just struggled with this one for a while and I thought I would share my findings...

It is fundamentally a permission issue. The cascading delete will only work if the user deleting the records has 'write' permissions to all the records needing to be deleted. So in the CloudKit Dashboard, the cascading delete will only work for the records created with the developer's iCloud account.

If you need to delete records that don't belong to the user deleting them, you can add 'write' permissions for a Record Type under Security.

enter image description here

like image 173
Yann Bodson Avatar answered Oct 04 '22 07:10

Yann Bodson