gpt4 book ai didi

swift - Firebase Firestore 时间戳至今问题

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

将我的代码升级到 Swift 5 后,Firestore 将 NSDate 返回为 FIRTimestamp。当我尝试将其作为 Date 接收时,它会抛出错误:

Could not cast value of type 'FIRTimestamp' (0x107aab8c0) to 'NSNumber' (0x10b8fbe00).

如何解决这个问题?

最佳答案

以下代码用于从 Firestore 获取时间戳值并将其转换为 NSDate

let timestamp: Timestamp = (filteredtotalArray[indexPath.row] as AnyObject).value(forKey: "requestedDate")! as! Timestamp
let RequestedDate = timestamp.dateValue()

关于swift - Firebase Firestore 时间戳至今问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55757854/

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