I'm parsing json object with Id (long) coming from a Java backend. the id is declared as CLong in my app. On iPhones5 < it works, but on iPhone5 the id is invalid value.
Asked
Active
Viewed 2,168 times
1 Answers
1
CLong
is a typedef
for Int
in the iOS SDK:
/// The C 'long' type.
public typealias CLong = Int
From the Swift docs:
- On a 32-bit platform, Int is the same size as Int32.
- On a 64-bit platform, Int is the same size as Int64.
Unless you need to work with a specific size of integer, always use Int for integer values in your code. This aids code consistency and interoperability. Even on 32-bit platforms, Int can store any value between -2,147,483,648 and 2,147,483,647, and is large enough for many integer ranges.
If you need to keep your Integer size consistent across multiple architectures, use Int32
. If you value is larger than 32 bits, you should look into handling overflows. Also consider sending a different data type rather than a long from your backend, such as a String
or NSNumber
.