The container controller must configure any necessary connections between itself and the built-in view controller in its prepareForSegue:sender: method.
In iOS programming, we have a template for this style of communication between view controllers. You can read about this in the "Coordinating efforts between view controllers" in the "Programming Guide for iOS" to view.
But I think itβs easier to understand with a concrete example. Let me use the Google Maps app for iPhone:

I donβt know exactly how this application is implemented. But suppose there is a top level AppViewController that controls the search bar (top) and the location bar (bottom), and it inserts the MapViewController container as a container.
There are several interactions between view controllers. When the user searches, the AppViewController must tell the MapViewController place some map markers and zoom in on one of them. When a user deletes a map marker, MapViewController must tell AppViewController to display information about that marker in the location bar below.
So here is the template.
First, we define the message protocol that the MapViewController (which is the built-in view controller) sends to the AppViewController (which is the container view controller):
@class MapMarker; @class MapViewController; @protocol MapViewControllerDelegate <NSObject> - (void)mapViewController:(MapViewController *)mapViewController didSelectMarker:(MapMarker *)marker; @end
We will make the AppViewController this protocol. Therefore, MapViewController does not need to know about AppViewController . He just needs a link to some object that conforms to the protocol. MapViewController must also understand a message that sets its markers and a message that zooms to a specific marker. Therefore, we declare MapViewController as follows:
@interface MapViewController : UIViewController @property (nonatomic, weak) id<MapViewControllerDelegate> delegate; - (void)setMarkers:(NSArray *)markers; - (void)zoomToMarker:(MapMarker *)marker; @end
Note that the delegate property is weak to avoid a save loop.
AppViewController must comply with MapViewControllerDelegate protocol. Usually we declare this correspondence in the class extension in AppViewController.m , since the correspondence should not be part of the public AppViewController interface. AppViewController also needs a reference to the MapViewController .
@interface AppViewController () <MapViewControllerDelegate> @property (nonatomic, strong) MapViewController *mapViewController; @end
Then we go to the storyboard, select the built-in segue and give it an identifier:

Now we can implement the prepareForSegue:sender: method to connect the properties:
@implementation AppViewController - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { if ([segue.identifier isEqualToString:@"MapEmbedding"]) { [self prepareForMapEmbeddingSegue:segue sender:sender]; } } - (void)prepareForMapEmbeddingSegue:(UIStoryboardSegue *)segue sender:(id)sender { self.mapViewController = segue.destinationViewController; self.mapViewController.delegate = self;
Note that AppViewController must also implement mapviewController:didSelectMarker: and MapViewController must implement setMarkers: and zoomToMarker: