MJQZ1347 MJQZ1347 - 10 months ago 58
iOS Question

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?


When declaring the timestamp as
, it throws an error:

var timestampQueryValue: Int64 = 1465222757817
.observeEventType(.ChildAdded, withBlock: {
(snapshot) -> Void in /* ... */ })

/* Error: Cannot convert value of type 'Int64'
to expected argument type 'AnyObject?' */


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