您可以使用以下代码删除记录:
database.deleteRecordWithID(CKRecordID(recordName: recordId), completionHandler: {recordID, error in
NSLog("OK or \(error)")
}
Run Code Online (Sandbox Code Playgroud)
其中database是您正在使用的CKDatabase.
但在您的情况下,更新以前创建的记录可能会更好.另一种解决方案是在creationDate上使用排序顺序时查询数据,如下所示:
query.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: false)]
Run Code Online (Sandbox Code Playgroud)
然后选择第一个,因为那是你保存的最后一个.一个很好的额外功能是您将在数据库中拥有历史记录.
| 归档时间: |
|
| 查看次数: |
3268 次 |
| 最近记录: |