我在完成块中包含以下内容:
dbRef.child("Employees").queryOrdered(byChild: "deptid").queryEqual(toValue: "100").observe(.childAdded, with: {
snapshot in
//add each result to an array
问题是每个结果都会触发完成。我需要在所有结果下载后触发,这意味着阻止。我怎么能这样做呢?
答案 0 :(得分:3)
尝试更改为: -
dbRef.child("Employees").queryOrdered(byChild: "deptid").queryEqual(toValue: "100").observeSingleEvent(of : .value, with:{ snapshot in
if let snapDict = snapshot.value as? [String:AnyObject]{
for each in snapDict{
let deptID = each.value["deptid"] as! String
}
}
})