gpt4 book ai didi

swift - 文档时间戳字段在展开为时间戳时抛出错误

转载 作者:行者123 更新时间:2023-11-30 10:42:43 24 4
gpt4 key购买 nike

我正在尝试从 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com