Why is my NSNotification its observer called multiple times?

后端 未结 5 2117
一个人的身影
一个人的身影 2020-12-15 04:48

Within an App I make use of several viewcontrollers. On one viewcontroller an observer is initialized as follows:

[[NSNotificationCenter defaultCenter] remov         


        
5条回答
  •  情话喂你
    2020-12-15 04:56

    It is possible that the class with the observer is, quite appropriately, instantiated multiple times. When you are debugging it will kinda look like the notification is being posted multiple times. But if you inspect self you might see that each time is for a different instance.

    This could easily be the case if your app uses a tab bar and the observer is in a base class of which your view controllers are subclasses.

提交回复
热议问题