如何从 Swift 中的 CloudKit 中删除资产?

How do you delete an asset from CloudKit in Swift?

我一直在互联网上搜索,但未能找到有关如何使用 Swift 删除 CloudKit 中的资产(例如图像)的任何信息?在CloudKit仪表盘中,您可以点击资产字段下的红色X将其删除;我只需要知道如何在 Swift 中执行此操作。当我尝试对此进行研究时出现的唯一搜索结果涉及删除记录。

摘自 CKAsset 文档:

You cannot delete asset data directly from the server. When you no longer want the data associated with an asset, remove all asset objects that point to that data from your records. For example, for a record that contains an asset as a field, set the value of the field to nil. When no asset objects refer to the data, the server lazily deletes the asset data at some point in the future. (Exactly when is not specified, but assume at least several days.)