将我的代码升级到 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/