Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 我的火力基地观察员不会停止观察_Ios_Swift_Firebase_Firebase Realtime Database_Observers - Fatal编程技术网

Ios 我的火力基地观察员不会停止观察

Ios 我的火力基地观察员不会停止观察,ios,swift,firebase,firebase-realtime-database,observers,Ios,Swift,Firebase,Firebase Realtime Database,Observers,在我的发言中: 我创建Firebase观察员如下: override func viewWillAppear(_ animated: Bool) 然后在 poolsRef.child(pID).child("lock").observe(.value, with: { snapshot in boxesRef.child(pID).observe(.value, with: { snapshot in coordRef.child(pID).child("x").observe(.val

在我的发言中:

我创建Firebase观察员如下:

override func viewWillAppear(_ animated: Bool) 
然后在

poolsRef.child(pID).child("lock").observe(.value, with: { snapshot in

boxesRef.child(pID).observe(.value, with: { snapshot in

coordRef.child(pID).child("x").observe(.value, with: { snapshot in

coordRef.child(pID).child("y").observe(.value, with: { snapshot in

poolsRef.child(pID).child("Winner").observe(.value, with: { snapshot in

playersRef.child("pID").observe(.value, with: { snapshot in
我将RemoveAllobserver称为:

override func viewDidDisappear(_ animated: Bool)
问题是,当我离开创建所有观察者的视图时,甚至认为在
视图中调用了removeAllobserver()
我完全不是一个不同的视图,如果我直接转到Firebase并对与上述观察者相关的数据进行更改,我可以看到应用程序仍在侦听,而它本不应该侦听

我如何解决这个问题

来自

在侦听器上调用removeObserverWithHandle或RemoveAllObserver不会自动删除在其子节点上注册的侦听器;您还必须跟踪这些引用或句柄才能删除它们

等等,其他观察者从

在侦听器上调用removeObserverWithHandle或RemoveAllObserver不会自动删除在其子节点上注册的侦听器;您还必须跟踪这些引用或句柄才能删除它们


等等,对于其他观察者

我不需要对observeSingleEvent执行任何操作,对吗?!写入Firebase时也是如此。。。我只是想确认一下这一点
observeSingleEvent
只侦听一次,但是
observeSingleEvent
侦听,直到您删除该observer。我不需要对
observeSingleEvent
执行任何操作,对吗?!写入Firebase时也是如此。。。我只是想确认一下这一点
observeSingleEvent
仅侦听一次,但
observe
将侦听,直到您删除该观察者
coordRef.removeAllObservers()

poolsRef.removeAllObservers()

boxesRef.removeAllObservers()

playersRef.removeAllObservers()
poolsRef.child(pID).child("lock").removeAllObservers()
poolsRef.child(pID).child("Winner").removeAllObservers()