ios - Firebase 服务器时间戳和非 64 位设备 : Integer literal '...' overflows when stored into 'Int'

标签 ios swift firebase 32bit-64bit iphone-64bit

我像这样在 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?' */

最佳答案

如果您显式指定 UInt64Int64(分别为无符号和有符号),您可以显式处理更大的数字,即使在 32 位设备上也是如此。

关于ios - Firebase 服务器时间戳和非 64 位设备 : Integer literal '...' overflows when stored into 'Int' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37660021/

相关文章:

ios - 如何以编程方式调整图像像素大小

ios - BLE writeValue 到外设

ios - 'NSPersistentStore' 类型的值永远不能为 nil,不允许比较

ios - iOS 上 Swift 中的 Xmartlabs Eureka 表单生成器存在问题

java - 删除 Cloud Firestore 数据库中的集合时建议使用哪些参数?

ios - iMessage 导航 Controller 栏在展开时隐藏

ios - 动画 UIButton 的标题更改

ios - 检测处理器 ArmV7 与 ArmV7s。 objective-C

angular - map 运算符不适用于 AngularFireAuth Observable

firebase - SwiftUI:从 DetailView 更新 Firestore