ios - JSONDecoder 在模拟器上运行正常时无法在真实设备上解码

标签 ios swift apple-watch

我有一个可以在模拟器上运行的 JSONDecoder,但在真实设备上运行时无法解码相同的数据,请帮忙。 在真机上运行会出现这个错误:

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))

我认为 16541228553 应该适合 Int? 它适合在模拟器上运行时。 谢谢。

最佳答案

您在标签中注意到这是 Apple Watch。我猜它是 Series 3,它是一个 32 位平台。这是一个 34 位数字,因此不适合。

模拟器不模拟硬件。它是一个 64 位 Mac 应用程序,链接与设备 SDK 匹配的库。所以在模拟器上,它不会溢出。

关于ios - JSONDecoder 在模拟器上运行正常时无法在真实设备上解码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72506998/

相关文章:

ios - Xcode Swift - 检测屏幕上颜色的触摸

ios - Watchkit 接口(interface) Controller 38mm 和 42mm 背景图像尺寸

javascript - 使用适用于 IOS 应用程序的 Phonegap FB 插件获取 facebook 用户电子邮件和用户名字/姓氏

ios - UIScrollView 启用分页滑动问题

swift - 如何在 NSURLSession 中使用 PUT 方法向 HTTPBody 添加数据?

ios - @NSManaged 有什么作用?

javascript - 在 iFrame 中引用时,“deviceorientation”不会在 iOS 浏览器中触发

iphone - if([一个字符串写入文件 : @"outfile" atomically: YES])

Xcode 无法安装 WatchKit App :"App installation failed Could not connect to the device."

Swift HealthKit 触发心率示例