How to Display the Destination Table in Your iOS App - dummies

How to Display the Destination Table in Your iOS App

By Neal Goldstein, Dave Wilson

You want your table view to appear automatically when the user accesses your iOS app. It should appear automatically when the user dismisses the UIAlertView— the one that displays the “Welcome to Road Trip” message the first time the app is launched.

The best way to handle this is to provide a method that will be called when the Alert is dismissed by the user, and then display the Destination table in that method. Here are the steps to do that:

  1. Add UIAlertViewDelegate to the MasterViewController’s comma-separated list of delegates in MasterViewController.h.

  2. Designate the MasterViewController as the UIAlertViewDelegate by adding the UIAlertViewDelegate line of code shown in Listing 20-17 to the viewDidLoad method in MasterViewController.m.

  3. Add the alertView:clickedButtonAtIndex: method to MasterVIewController.m. The simple code displays the Destination table as desired.

- (void) createDestinationModel:(int)destinationIndex {
... // previous code
if(appDelegate.destinationPreference == nil) {
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Welcome to Road Trip"
message:@"Please select a Destination from the
Road Trip Menu"
alert.delegate = self;
[alert show];

And use this simple bit of code to display the Destination Table.

- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {
[self performSegueWithIdentifier:@"Destination"