Created
March 12, 2014 10:19
-
-
Save keicoder/9504247 to your computer and use it in GitHub Desktop.
objective-c : prepareForSegue method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//prepareForSegue method | |
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
if ([[segue identifier] isEqualToString:@"addCourse"]) { | |
//ex | |
//1. to typical view controller with modal segue | |
//AddCourseViewController *acvc = (AddCourseViewController *)[segue destinationViewController]; | |
//2. embed in navigation controller with modal segue | |
UINavigationController *nav = [segue destinationViewController]; | |
AddCourseViewController *acvc = (AddCourseViewController *)[nav topViewController]; | |
acvc.delegate =self; | |
Course *newCourse = (Course *) [NSEntityDescription insertNewObjectForEntityForName:@"Course" inManagedObjectContext:[self managedObjectContext]]; | |
acvc.currentCourse = newCourse; | |
} | |
if ([[segue identifier] isEqualToString:@"showDetail"]) { | |
//3. to typical view controller with push segue | |
DisplayEditViewController *dvc = (DisplayEditViewController *) [segue destinationViewController]; | |
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow]; | |
Course *selectedCourse = (Course *) [self.fetchedResultsController objectAtIndexPath:indexPath]; | |
dvc.currentCourse = selectedCourse; | |
} | |
} | |
/* | |
Again | |
When Using Modal Segue | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
if ([[segue destinationViewController] isEqualToString:@"Modal to MyVC"]) | |
{ | |
UINavigationController *nav = [segue destinationViewController]; | |
MyViewController *vc = [nav topViewController]; | |
//setup vc | |
} | |
} | |
When Using Push Segue | |
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender | |
{ | |
if ([[segue destinationViewController] isEqualToString:@"Push to MyVC"]) | |
{ | |
MyViewController *vc = [segue destinationViewController]; | |
//setup vc | |
} | |
} | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment