iosswiftfirebase32bit-64bitiphone-64bit

Firebase server timestamp and non 64 bit device: Integer literal '...' overflows when stored into 'Int'


I have stored messages in Firebase like so:

messageObject["timestamp"] = FIRServerValue.timestamp()

The objects have a child like: timestamp: 1465222757817. The problem is that older non 64 bit devices cannot handle Integers of that length. What would be a good workaraound for this problem?

Edit:

When declaring the timestamp as Int64, it throws an error:

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?' */

Solution

  • You can explicitly deal with larger numbers, even on 32 bit devices, if you explicitly specify UInt64 or Int64 (unsigned, and signed, respectively).