'How to store long in a Swift array?

I got a couple user IDs I want to send in an array, but can't figure out the correct Swift 3 syntax for creating an array with very long integers. I tried casting, @ prefix and using as AnyObject, but that did not work.

let idArray = [10211420262370680, 10211420262370680]

Error: integer literal overflows when stored into int

What is the correct way to create an array with such long integers?



Solution 1:[1]

Signed long's array:

let signed64BitIntegerArray: [Int64] =      [-10211420262370680, 10211420262370680]

Unsigned long's array:

let unsigned64BitIntegerArray: [UInt64] =   [ 10211420262370680, 10211420262370680]

Solution 2:[2]

If you need C interop/FFI, use CLong or CUnsignedLong.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Solomon Ucko