Skip to content

Instantly share code, notes, and snippets.

@benvium
Created April 21, 2012 13:15
Show Gist options
  • Save benvium/2437046 to your computer and use it in GitHub Desktop.
Save benvium/2437046 to your computer and use it in GitHub Desktop.
Get the destination ViewController from an iOS5 StoryBoard segue
// 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
#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