title: Multiple Segue from Table View Controller
body: <p>I have a table view with different information the user can update. One of them is "pilot information". When the user clicks on this row they are taking to another view controller where they fill out information on the pilot. (name phone number etc)
  They can then hit save or cancel both of which return them to the previous table view controller. What I want to do is have the user be able to click on pilot information again, and view the data they just entered and edit it if they choose. My solution to this was to add another segue and give it a unique identifier using the following code. (pilot is the name of the entity in my core data model, updatepilot is the name I gave the segue.)</p>
  
  <pre><code>- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
  {
      if ([[segue identifier] isEqualToString:@"UpdatePilot"]) {
          NSManagedObject *selectedPilot = [self.pilots objectAtIndex:[[self.tableView indexPathForSelectedRow] row]];
          PilotViewController *destViewController = segue.destinationViewController;
          destViewController.pilot = selectedPilot;
      }
  }
  </code></pre>
  
  <p>!<a href="http://tinypic.com/r/2ihbera/8" rel="nofollow">http://tinypic.com/r/2ihbera/8</a></p>
  
  <p>However, I get the error use of undeclared identifier 'destviewcontroller" did you mean UIViewController? Is there something I'm not seeing here? any help would be appreciated!</p>
  
  <pre><code>#import "PilotViewController.h"
  
  @interface PilotViewController ()
  
  @end
  
  @implementation PilotViewController
  - (NSManagedObjectContext *)managedObjectContext {
      NSManagedObjectContext *context = nil;
      id delegate = [[UIApplication sharedApplication] delegate];
      if ([delegate performSelector:@selector(managedObjectContext)]) {
          context = [delegate managedObjectContext];
      }
      return context;
  }
  
  @synthesize pilot;
  
  
  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
  {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
  
          // Custom initialization
      }
      return self;
  }
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
  
      if (self.pilot) {
          [self.nameField setText:[self.pilot valueForKey:@"pilotName"]];
          [self.emailField setText:[self.pilot valueForKey:@"pilotEmail"]];
          [self.phoneField setText:[self.pilot valueForKey:@"pilotPhone"]];
          [self.insuranceField setText:[self.pilot valueForKey:@"pilotInsurance"]];
  
  
  
      }
      // Do any additional setup after loading the view.
  }
  
  - (void)didReceiveMemoryWarning
  {
      [super didReceiveMemoryWarning];
      // Dispose of any resources that can be recreated.
  }
  
  //Code created for cancel and save buttons
  - (IBAction)cancel:(id)sender {
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  
  - (IBAction)save:(id)sender {
  
      NSManagedObjectContext *context = [self managedObjectContext];
  
      if (self.pilot) {
          // Update existing Pilot
          [self.pilot setValue:self.nameField.text forKey:@"pilotName"];
          [self.pilot setValue:self.phoneField.text forKey:@"pilotPhone"];
          [self.pilot setValue:self.insuranceField.text forKey:@"pilotInsurance"];
          [self.pilot setValue:self.emailField.text forKey:@"pilotEmail"];
  
      } else {
          // Create a new pilot
          NSManagedObject *newPilot = [NSEntityDescription insertNewObjectForEntityForName:@"Pilot" inManagedObjectContext:context];
          [newPilot setValue:self.nameField.text forKey:@"pilotName"];
          [newPilot setValue:self.phoneField.text forKey:@"pilotPhone"];
          [newPilot setValue:self.insuranceField.text forKey:@"pilotInsurance"];
           [newPilot setValue:self.emailField.text forKey:@"pilotEmail"];
      }
  
      NSError *error = nil;
      // Save the object to persistent store
      if (![context save:&amp;error]) {
          NSLog(@"Can't Save! %@ %@", error, [error localizedDescription]);
      }
  
      [self dismissViewControllerAnimated:YES completion:nil];
  }
  @end
  </code></pre>