snapshot.exists() 保持其值为 true 时someValue == nil.
我不知道如何snapshot.exists()在初始查询后重置该值。如何将数据库调用设置为仅在我调用它时触发?喜欢以正确的方式移除观察者?
let ref = Database.database().reference()
ref.child("matches").child("available").queryOrdered(byChild: "opponent_1").queryEqual(toValue: potential_oponnent).observeSingleEvent(of: .value, with: { (snapshot) -> Void in
if (snapshot.exists()) && someValue != nil {
}else {
ref.removeAllObservers()
}
我需要使用ref.removeObserver(withHandle: )orref.removeAllObservers()吗?