Created
April 21, 2012 13:15
-
-
Save benvium/2437046 to your computer and use it in GitHub Desktop.
Get the destination ViewController from an iOS5 StoryBoard segue
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
// From http://stackoverflow.com/questions/8041237/how-to-set-the-delegate-with-a-storyboard | |
#import <Foundation/Foundation.h> | |
@interface UIStoryboardSegue (topLevelDestinationViewController) | |
@property (readonly) id topLevelDestinationViewController; | |
@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 "UIStoryboardSegue+topLevelDestinationViewController.h" | |
@implementation UIStoryboardSegue (topLevelDestinationViewController) | |
- (id)topLevelDestinationViewController { | |
id dest = self.destinationViewController; | |
if ([dest isKindOfClass:[UINavigationController class]]) { | |
UINavigationController* nav = dest; | |
dest = nav.topViewController; | |
} | |
return dest; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment