Prerna chavan
Prerna chavan

Reputation: 3249

Communication between two childViewControllers

What is the best way to communicate between two child view controllers ? I know the use of delegates to communicate between child and parent view controller but i am not able to get how to communicate between child view controllers of same parent view controller.

Upvotes: 2

Views: 482

Answers (1)

pbx
pbx

Reputation: 1137

Well you could solve it with outlets what is the worse solution to my mind. Or you could inform your parentViewController about everything that happens and let him do the work (e.g. inform all objects that need specific information).

You would do it like this for example:

[childViewControllerInstance.parentViewController methodToCall];

In the class of the parent view controller you could then do everything you want and perform actions on whatever object is needed.

EDIT:

Please try

[childViewControllerInstance.parentViewController performSelector:@selector(methodToCall:) 
                 withObject:yourObjectToPass];

Upvotes: 2

Related Questions