database - 无法转换“用户?”类型的值 到预期的参数类型“字符串”
问题描述
所以我试图检查当前用户是否存在并且我得到错误:无法转换类型“用户?”的值 到预期的参数类型“字符串”。我假设我需要转换用户?到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")
}
})
解决方案
React Native 中的数据类型并不严格。本机反应中没有数据类型。谢谢。
推荐阅读
- c# - 遍历通过反射动态调用的列表
- neo4j - Neo4j APOC 使用主键而不是内部 id 导出/导入
- asp.net - NWebsec CSP for Google Analytics on ASP.NET -> 如何包含所有 Google 域
- python - Pandas 根据时间戳分配 5-1 范围内的点,最近获得最大点
- apache-flink - kafka flink连接报错显示NoSuchMethodError
- c++ - 具有多个参数的模板类特化,其中一个模板参数是模板本身
- python - 如何从 hyperopt hp.choice 中提取选定的超参数?
- javascript - 如何通过从特定点滚动到另一个点来动画元素?
- ios - CoreData + Cloudkit - 自动MergesChangesFromParent
- spring-boot - 无法打开 JPA EntityManager 进行事务处理;嵌套异常是 java.lang.NoSuchMethodError