我正在尝试从 firestore 检索带有时间戳值的文档。当我像这样打开它时:
let dateCreated = document.get("created") as! Timestamp
它抛出错误:
Could not cast value of type '__NSTaggedDate' (0x1b3cf66a0) to 'FIRTimestamp' (0x104bec868).
我尝试过使用 document.data["created"] 作为!时间戳
但它抛出相同的错误。
是否有其他方法从 firestore 检索时间戳?或者我的代码中缺少什么东西吗?如果有任何帮助,我将不胜感激
最佳答案
想通了。 Firestore 现在有一个名为 areTimestampsInSnapshotsEnabled
的设置,您需要在 appDelegate 中将其设置为 true。
关于swift - 文档时间戳字段在展开为时间戳时抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56449173/