小编bwc*_*ley的帖子

在卸载应用程序后将用户注销 - Firebase

从手机上卸载应用程序后,我的应用程序不会注销当前用户.我不希望用户卸载该应用程序,当他们重新安装时,他们已经登录.

我认为这与其钥匙串访问有关吗?不确定.我想也许我需要在删除应用程序后取消对用户进行身份验证,但无法检查该情况.最接近的是运行该applicationWillTerminate函数,但如果我把FIRAuth.auth()?.signOut()它放在那里,它会在每次应用程序被杀时签署我的用户.我不希望这样.

我该怎么做才能做到这一点?

ios firebase swift firebase-authentication

7
推荐指数
1
解决办法
1928
查看次数

IBAction函数的多个参数

我目前有一个函数从数据库收集时间并返回它以供其他函数使用.它需要一个参数,该参数存储在应用程序的另一部分中,以便从数据库中收集值.

当我想在IBAction函数中调用此函数时,我的问题出现了.

这是我的函数代码:

func getDBValue(place: GMSPlace) -> Int {

    var expectedValue = 0

    databaseRef.child("values").child(place.placeID).observe(.value, with: { (snapshot) in
        let currentValue = snapshot.value as? [Int]

        if currentValue == nil {
            self.noValue()
            expectedValue = 0
        } else {
            let sumValue = currentValue?.reduce(0, +)

            let avgValue = sumValue! / (currentValue?.count)!

            print("The current value is \(String(describing: avgValue))")

            expectedValue = avgValue

            self.valueLabel.text = String(describing: avgValue)
        }

    })

    print("This is the expected WT: \(expectedWaitTime)")

    return expectedValue

}
Run Code Online (Sandbox Code Playgroud)

这是我的IBAction函数的代码,它有多个参数的问题:

@IBAction func addValuePressed(_ sender: Any, place: GMSPlace) { …
Run Code Online (Sandbox Code Playgroud)

parameters ibaction swift

0
推荐指数
1
解决办法
1190
查看次数

如何找到数组的平均值 - Swift

我遇到了一个问题,我不知道如何找到数组的平均值.这是我的问题:

  1. 如何将数组中的所有数字相加?
  2. 如何查找数组中有多少索引?
  3. 如何获取此信息并从阵列中收集平均值?

虽然所有这些看似简单而且相当基础,但我不确定如何做到这一点.有帮助吗?

arrays swift

-2
推荐指数
3
解决办法
6901
查看次数