Here's the problem I have: Some smart guy saved timestamps in our database as strings. So dates for created documents look like this: 1569260406765
Here's my code:
tasksRef.getDocuments { (querySnapshot, err) in
if let docs = querySnapshot?.documents {
for docSnapshot in docs {
print("Snapshot:" ,docSnapshot.data())
let dateCreated = docSnapshot.get("dateCreated")
let date = NSDate(timeIntervalSince1970: dateCreated as! TimeInterval)
print("dateCreated:", date)
self.recentOrderNowsFirst.text = "\(String(describing: dateCreated))"
}
}
}
which gets me this error:
Could not cast value of type 'FIRTimestamp' (0x101df5660) to 'NSNumber'
How can I fix this? Appreciate any help.