I have a view controller "A" which is registered as an observer like this,
-(void)viewWillAppear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:@"localActionTaken" object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(receiveLocalActionNotification:) name:@"localActionTaken" object:nil];
}
I am also removing observer in dealloc method.
From view controller "A" user goes to view controller "B" where "localActionTaken" notification is posted.
Everything works fine till this
Now I have another view controller "C" from which user is pushed to view controller "A" and from "A" to "B". But the issue is in this "C"->"A"->"B", if notification is triggered in "B" then observerver "A" is notified twice!
Please let me know if I am missing here anything.
Note : I am using ECSlidingview and "A" and "C" are top view controllers.
----------------- Update -----------------
I had to move removeObserver to viewWillDisappear based on check for specific view controllers in stack.