I’m : a web and mobile developer based in the Manning Valley, Australia.

Loading a new view controller

I've just been working on an on-boarding process for an app and needed a way of replacing the app's root view controller. Turned out to be as easy as the following snippet.

- (void)viewDidLoad {
    [super viewDidLoad];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    AppDelegate *appDelegate = [UIApplication sharedApplication].delegate;
    appDelegate.window.rootViewController = [storyboard instantiateInitialViewController];
    [appDelegate.window makeKeyAndVisible];