首页 > 解决方案 > 无法转换“用户?”类型的值 到预期的参数类型“字符串”

问题描述

所以我试图检查当前用户是否存在并且我得到错误:无法转换类型“用户?”的值 到预期的参数类型“字符串”。我假设我需要转换用户?到String,有什么想法吗?

let user = Auth.auth().currentUser
        let databaseRef = Database.database().reference()
        databaseRef.child("Users").queryOrdered(byChild: "uid").observeSingleEvent(of: .value, with: { (snapshot) in
            if snapshot.hasChild(user){

                print("user does exist")

            }else{

                print("user does not exist")
            }


        })

标签: databasefirebase

解决方案


React Native 中的数据类型并不严格。本机反应中没有数据类型。谢谢。


推荐阅读