Inside of navigationController, when I’m in a ChildViewController and when the user taps on Back Button. I would love to send some data to the parentViewController before I go away.
Is any simple why to do this besides using
-(void)viewWillDisappear;
First, because this ChildViewController also has its own child, and when it gets pushed, viewWillDisappear gets called as well.
Second, when I user hits home button. it get called.(I guess)
Please, any reasonable and proper way to do this?
You can do this in any of following ways:
Send a notification when the second controller is going away and have the parent listen for it.
Create a delegate protocol that lets the second controller reference a parent method directly.
Use the parent’s
viewWillAppear:and check theisMovingToParentViewControllerproperty for whether it’s just re-appearing.and apply what is best for your value passing conditions and availability of values.