如何解决错误“模糊使用'增量'"在iOS Firestore上增量() [英] How to fix error "Ambiguous use of 'increment'" on iOS Firestore increment()
问题描述
在尝试使用Swift在iOS中使用Firebase FieldValue.increment(1)
时,我收到编译器错误.该错误仅显示歧义使用'increment'"
I receive a compiler error when trying to use firebase FieldValue.increment(1)
in iOS using swift. The error only says "Ambiguous use of 'increment'"
我已将所有吊舱更新为所使用的所有Firebase吊舱的当前版本.更具体地说,我使用的是Firebase(5.20.2)和FirebaseFirestore(1.2.1).
I have updated all my pods to the current versions of all firebase pods used. More specifically I am on Firebase(5.20.2) and FirebaseFirestore (1.2.1).
My code (below) is almost exactly the same as the example in the docs Seen at the bottom of this page
如何解决此错误并使应用编译?
How can I fix this error and get the app to compile?
let docRef = db.collection("metadata").document("permanentConversions")
docRef.updateData([
"total": FieldValue.increment(1)
])
推荐答案
如注释中所述,通过将示例中的代码更改为
FieldValue.increment(Int64(1))
.
编译器为增量运算符提供了double或int64选项,我想它不知道选择哪个.
As noted in the comments, the "Ambiguous use of 'increment'" error is solved for me by changing the code in the example to
FieldValue.increment(Int64(1))
.
The compiler provides an option of double or int64 for the increment operator and I guess it does not know which one to choose.
这篇关于如何解决错误“模糊使用'增量'"在iOS Firestore上增量()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!