有人可以尝试解释我需要做的步骤吗?当我尝试在Xcode中定义数据库时,我遇到了很多错误。
dbRef.child("class").observeSingleEvent(of: .value, with:
{ (snapshot) in
let value = snapshot().value? as? [String: AnyObject]
let description = value? ["desciption"] as? [Any]
let owner = value? ["owner"] as? [Any]
let participant = value? ["participant"] as? [Any]
let time = value? ["time"] as? [Any]
print("description: \(String(describing: description))")
print("owner: \(String(describing: owner))")
print("participant: \(String(describing: participant))")
print("time: \(String(describing: time))")
答案 0 :(得分:0)
您不需要snapshot().value
上的()。设为snapshot.value as? [String: AnyObject]
即可删除错误"无法调用非功能类型的值' DataSnapshot'"
基本上可以从字面上理解错误。快照(类型为DataSnapshot)不是函数,因此您无法将其称为函数,即snapshot()