为什么FieldValue.increment()在Swift中给我一个错误?

问题描述 投票:1回答:1

所以我唯一更改的是添加:

pod 'Geofirestore'

到我使用Firestore的IOS应用的podfile中,具有以下这些:

  pod 'Firebase/Core'
  pod 'Firebase/Firestore'
  pod 'Firebase/Auth'
  pod 'Firebase/Storage'
  pod 'GooglePlaces'
  pod 'GoogleMaps'
  pod 'Geofirestore'
  pod 'InstantSearch', '~> 5.0'

并且突然间,我在Firestore中的代码更新字段值的代码行抛出错误。行:

db.collection("people").document(userID!).updateData(["listsCount": FieldValue.increment(Int64(1))])

现在给我错误:

类型'FieldValue'没有成员'increment'

对于我的一生,我不知道突然发生了什么。任何帮助表示赞赏。

ios swift firebase google-cloud-firestore geofirestore
1个回答
0
投票

我能够通过在更新字段之前将我的值初始化为Double来解决此问题。这样,Firebase知道如何解释可以为DoubleInt64的增量。

   let value: Double = 1

    ref.updateData([
        "likeCount" : FieldValue.increment(value)

    ])
© www.soinside.com 2019 - 2024. All rights reserved.