我像这样在 Firebase 中存储消息:
messageObject["timestamp"] = FIRServerValue.timestamp()
对象有一个 child ,如:timestamp: 1465222757817
。问题是较旧的非 64 位设备无法处理该长度的整数。什么是解决这个问题的好方法?
编辑:
当声明时间戳为Int64
时,会抛出一个错误:
var timestampQueryValue: Int64 = 1465222757817
self.chatRef.queryOrderedByChild("timestamp")
.queryStartingAtValue(timestampQueryValue)
.observeEventType(.ChildAdded, withBlock: {
(snapshot) -> Void in /* ... */ })
/* Error: Cannot convert value of type 'Int64'
to expected argument type 'AnyObject?' */
最佳答案
如果您显式指定 UInt64
或 Int64
(分别为无符号和有符号),您可以显式处理更大的数字,即使在 32 位设备上也是如此。
关于ios - Firebase 服务器时间戳和非 64 位设备 : Integer literal '...' overflows when stored into 'Int' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37660021/