Last active
February 11, 2016 23:41
-
-
Save brendanjerwin/5677203 to your computer and use it in GitHub Desktop.
A pattern for increasing the testability of `prepareForSegue:sender:`
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
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { | |
DDLogVerbose(@"prepareForSegue: %@", segue.identifier); | |
SEL selector = NSSelectorFromString([NSString stringWithFormat:@"%@ToController:WithSegue:", segue.identifier]); | |
if ([self respondsToSelector:selector]) { | |
#pragma clang diagnostic push | |
#pragma clang diagnostic ignored "-Warc-performSelector-leaks" | |
[self performSelector:selector withObject:segue.destinationViewController withObject:segue]; | |
#pragma clang diagnostic pop | |
} else { | |
NSException *ex = [NSException exceptionWithName:@"Segue Handler Selector Not Found" reason:[NSString stringWithFormat:@"There is no \"ToController\" selector to handle the segue: %@", segue.identifier] userInfo:@{ @"segue" : segue}]; | |
DDLogError(@"%@", ex); | |
[ex raise]; | |
} | |
} |
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
-(void)entityListSegueToController:(TNWEntityTableViewController *)controller WithSegue:(UIStoryboardSegue *)segue { | |
DDLogVerbose(@"Segue to Entity List with Controller: %@ and segue: %@", controller, segue); | |
[controller beginLoadEntity:self.selectedEntityList]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment