Last active
December 25, 2015 07:49
-
-
Save rcdilorenzo/6942398 to your computer and use it in GitHub Desktop.
Get the main storyboard in an iOS app as set by the .plist file. (You may need to change the return type to id if you are on 6.1 or earlier.)
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 UIStoryboard (LDMain) | |
+ (instancetype)mainStoryboard; | |
@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 "UIStoryboard+LDMain.h" | |
UIStoryboard *_mainStoryboard = nil; | |
@implementation UIStoryboard (LDMain) | |
+ (instancetype)mainStoryboard { | |
if (!_mainStoryboard) { | |
NSBundle *bundle = [NSBundle mainBundle]; | |
NSString *storyboardName = [bundle objectForInfoDictionaryKey:@"UIMainStoryboardFile"]; | |
_mainStoryboard = [UIStoryboard storyboardWithName:storyboardName bundle:bundle]; | |
} | |
return _mainStoryboard; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment