How to fix error “Ambiguous use of 'increment'” on iOS Firestore increment()

泄露秘密 提交于 2020-01-23 06:09:24

问题


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'"

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

回答1:


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.



来源:https://stackoverflow.com/questions/55841639/how-to-fix-error-ambiguous-use-of-increment-on-ios-firestore-increment

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!