Adding observer to NSNotificationCenter second time causes EXC_BAD_ACCESS
-
12-11-2019 - |
Question
Hypothetical scenario:
In my viewDidLoad
method I am adding view controller as an observer for custom notification (say, notification MyFooNotification
). Later in the process when view is loaded the notification gets posted and controller processes it. When I leave the controller with it's view I DO NOT remove the observer (intentionally) in viewDidUnload
. Next time when opening the view, the observer gets added again, but now when the observed notification gets posted - I get EXC_BAD_ACCESS
.
Can anyone explain why this is happenning.
P.S. I do know that I should remove it in viewDidUnload
I'm just curious about the lower level details.
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow