CKReference .DeleteSelf attribute has no effect

不打扰是莪最后的温柔 提交于 2019-12-07 02:22:55

问题


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?


回答1:


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.




回答2:


If you are deleting via CloudKit Dashboard you have to wait before switching record types to check the other end of the reference. More than likely you switched before the delete actually happened. You can use Safari's Web Inspector on the Network tab to check when the delete has actually finished. It takes a very long time to delete multiple records.



来源:https://stackoverflow.com/questions/32788980/ckreference-deleteself-attribute-has-no-effect

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!