iOS performs the following tasks when a segue is triggered:
-
It instantiates the destination view controller.
-
It instantiates a new segue object that holds all the information for the segue being triggered.
Note: Apopoverseguealsoprovidesapropertythatidentifiesthepopovercontrollerusedtocontrol the destination view controller.
-
It calls the source view controller’sprepareForSegue:sender:method, passing in the new segue objectand the object that triggered the segue.
-
It calls the segue’s performmethod to bring the destination controller onto the screen. The actual behaviordepends on the kind of segue being performed. For example, a modal segue tells the source view controllerto present the destination view controller.
-
It releases the segue object and the segue is complete.
Configuring the destination controller in a segue
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"ShowSightingsDetails"])
{
DetailViewController *detailViewController = [segue
destinationViewController];
detailViewController.sighting = [self.dataController
objectInListAtIndex:[self.tableView indexPathForSelectedRow].row];
}
if ([[segue identifier] isEqualToString:@"ShowAddSightingView"])
{
AddSightingViewController *addSightingViewController = [[[segue
destinationViewController] viewControllers] objectAtIndex:0];
addSightingViewController.delegate = self;
} }