尝试在 iOS 中使用 swift 使用 firebase FieldValue.increment(1)
时,我收到编译器错误。该错误仅表示“‘增量’的使用不明确”
我已将所有 Pod 更新为所有使用的 Firebase Pod 的当前版本。更具体地说,我使用 Firebase(5.20.2) 和 FirebaseFirestore (1.2.1)。
我的代码(如下)与文档 Seen at the bottom of this page 中的示例几乎完全相同
如何修复此错误并让应用程序编译?
let docRef = db.collection("metadata").document("permanentConversions")
docRef.updateData([
"total": FieldValue.increment(1)
])
最佳答案
正如评论中所指出的,“‘增量’的使用不明确”错误是通过将示例中的代码更改为来解决的
FieldValue.increment(Int64(1))
。
编译器为增量运算符提供了 double 或 int64 选项,我猜它不知道该选择哪一个。
关于firebase - 如何修复 iOS Firestore Increment() 上的错误 "Ambiguous use of ' Increment'",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55841639/