Last active
October 12, 2015 19:08
-
-
Save advantis/4073161 to your computer and use it in GitHub Desktop.
Random thoughts on storyboard segues
This file contains 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
// 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