Skip to content

Instantly share code, notes, and snippets.

@advantis
Last active October 12, 2015 19:08
Show Gist options
  • Save advantis/4073161 to your computer and use it in GitHub Desktop.
Save advantis/4073161 to your computer and use it in GitHub Desktop.
Random thoughts on storyboard segues
// Thought #1
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
[self performSelector:NSSelectorFromString(segue.identifier)
withObject:segue.destinationViewController];
#pragma clang diagnostic pop
}
// Thought #2
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
typedef void(^SegueAction)(id destination);
NSDictionary *mapping = @{
@"addAlarm" : ^(UINavigationController *navigator) {
[navigator.viewControllers[0] setAlarm:[HDAlarm new]];
},
@"editAlarm" : ^(AlarmEditViewController *editor) {
editor.alarm = [_dataController objectAtIndexPath:self.tableView.indexPathForSelectedRow];
}
};
SegueAction action = mapping[segue.identifier];
action(segue.destinationViewController);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment