gpt4 book ai didi

ios - iOS 上的 AWSDynamoDBObjectMapper 将 Bool 值设置为 1 而不是 true?

转载 作者:行者123 更新时间:2023-11-30 13:36:16 24 4
gpt4 key购买 nike

所以我这里有一个奇怪的。在 iOS9.3 上,AWSDynamoDBObjectMapper 在 DynamoDB 表中将 Bool 正确设置为 true 或 false。然而,在 iOS9.2.1 上运行相同的代码,它会将相同的值设置为 Int 0 或 1。当我尝试根据这些值搜索其中的项目时,这会破坏整个数据库。

有人遇到过这种情况吗?

我正在使用 Swift 和最新的适用于 iOS 的 AWS 开发工具包。

最佳答案

在模型上,您必须使用 NSNumber 来表示 Boolean

For boolean values, you need to use NSNumber when you are defining the model class. You can pass true and false as follows: NSNumber(bool:
true)
and NSNumber(bool: false). This is an inherent limitation of the object mapping library the DynamoDB Object Mapper uses.

来源:aws-sdk-ios on Github

关于ios - iOS 上的 AWSDynamoDBObjectMapper 将 Bool 值设置为 1 而不是 true?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36036491/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com