I have a JSONDecoder that works on simulator, but it can’t decode the same data when running on real device, please help.
This error will happen when running on real device:
dataCorrupted(Swift.DecodingError.Context(
codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0),
CodingKeys(stringValue: "market_cap", intValue: nil)],
debugDescription: "Parsed JSON number <16541228553> does not fit in Int.",
underlyingError: nil))
I think 16541228553 should fit in Int?
It fits when running on simulator.
Thanks.
2
Answers
There is very little information about the question but I guess the
market_cap
property in your model isInt
.Changing with
Decimal
would fix the problemYou note in the tags that this is an Apple Watch. I’m guessing it’s a Series 3, which is a 32-bit platform. This is a 34-bit number, so it doesn’t fit.
The Simulator does not emulate hardware. It’s a 64-bit Mac app that links libraries that match the device SDK. So on Simulator, it doesn’t overflow.