The prepareForSegue method is called just before a segue is performed and allows you to pass variables to the new view controller that is the segue’s destination.
While the prepareForSegue for segue call hasn’t changed between iOS 5 and iOS 6 there has been a new method, shouldPerformSegueWithIdentifier, that has been introduced in iOS 6 which allows you to specify if you want the segue to be be performed or not.. It’s very useful especially for things like only displaying one popover at a time
I’ve included an example of how to to use it below:
-(void) prepareForSegue:(UIStoryboardPopoverSegue *)segue sender:(id)sender { if ([[segue identifier] isEqualToString:@"Next View"]) { //The segue is to the a View Controller called NextViewController (NextViewController *nvc = (NextViewController *) segue.destinationViewController; //Set properties in the view controller - note the views outlets are not set yet nvc.stringProperty1 = @"This Is Property 1"; nvc.property2 = @"This Is Property 2"; //Set self as the delegate nvc.delegate = self; } } - (BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender { if ([identifier isEqualToString:@"Crazy View" ]) { return NO; } return YES; } }
Thank you very much for this example..i was helpless for my code validation..but because of your this example i solved it..
No worries, glad it helped