Created
July 30, 2014 10:07
-
-
Save tomohisa/bee735038bf89acd3202 to your computer and use it in GitHub Desktop.
Storyboard by viewController factory method
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
#import <UIKit/UIKit.h> | |
@interface UIViewController (JTCAddition) | |
+(instancetype) viewControllerFromSameNameStoryboard; | |
+(UINavigationController*) viewControllerFromSameNameStoryboardInNavigationController; | |
@end |
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
#import "UIViewController+JTCAddition.h" | |
@implementation UIViewController (JTCAddition) | |
+(instancetype) viewControllerFromSameNameStoryboard { | |
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:NSStringFromClass(self) bundle:nil]; | |
if (!storyboard) { | |
return nil; | |
} | |
return [storyboard instantiateInitialViewController]; | |
} | |
+(UINavigationController*) viewControllerFromSameNameStoryboardInNavigationController { | |
UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:[self viewControllerFromSameNameStoryboard]]; | |
return nav; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment