Basically, I have a view1 which at some point, calls view2 (via presentModalViewController:animated:
). When a certain UIButton
in view2 is pressed,
If you implement the removal of Observer in the viewWillDisappear:
or viewDidDisappear:
then you should not leave the addition of the observer in the viewDidLoad
.
Instead put the addition of the observer in the viewWillAppear:
. The problem you are having is because when any view is shown onto of the UIViewController
view the removal of your observer will occur and since you added observer in viewDidLoad
which will happen only once, it will be lost.
Keep in mind that this approach works well for objects you do not wish to observer while your main view is not in the fore front.
Also Keep in mind that viewDidUnload
has been depreciated too.